How do i get wforms 3.0 validation working?

32 views
Skip to first unread message

rel...@gmail.com

unread,
Nov 3, 2008, 5:32:55 PM11/3/08
to wForms Group
I am trying to force the feature on that will not submit hidden form
values, i checked the 2.0 documentation and it said

wFORMS.behaviors.validation.submitSwitchedOffFields = false;

i tried adding this right below

<script type="text/javascript" src="/lib/wforms.js"></script>

and it did nothing

i even added a class="required" to one of the fields, but that
wouldn't
work either

cedsav

unread,
Nov 3, 2008, 5:46:30 PM11/3/08
to wForms Group
We left that out of v3 (the implementation in v2 was buggy).

You can use this instead:
http://code.google.com/p/wforms/source/browse/tags/3.0/customization/wforms_custom_clear_switch.js

(download a copy and include the file after loading wforms.js)

This clears field values when the fields are switched off. Note that
the fields are submitted anyway (they're just blank), so that may not
do exactly what you need.

rel...@gmail.com

unread,
Nov 4, 2008, 2:33:00 PM11/4/08
to wForms Group
thanks, i modified it to get the disabled behavior instead of empty
values because i am submitting the form via "GET" and dont want the
variables taking up the extra url if not neccessary here is the
updated file

/***
* wForms 3.0 - a javascript extension to web forms.
*
* Customization Script:
* Enable or disable the fields inside an switched off element .
*
*
* wForms 3.0 uses base2 - copyright 2007 Dean Edwards
***/

if (typeof(wFORMS) == "undefined") {
throw new Error("wFORMS core not found. This behavior depends
on the wFORMS core.");
}
if (typeof(wFORMS.behaviors['switch']) == "undefined") {
throw new Error("wFORMS switch behavior not found. This
behavior depends on the wFORMS switch behavior.");
}

/**
* Handler for the 'switchOff' and 'switchOn' events.
*/
new function(_) {

// preserve any existing handler
if(wFORMS.behaviors['switch'].onSwitchOff)
var _onSwitchOff =
wFORMS.behaviors['switch'].onSwitchOff;

wFORMS.behaviors['switch'].onSwitchOff = function(element)
{
// clear field values
wFORMS.helpers.disableFieldValues(element);
// run any other existing handler
if (_onSwitchOff) _onSwitchOff(element);
}

// preserve any existing handler
if(wFORMS.behaviors['switch'].onSwitchOn)
var _onSwitchOn =
wFORMS.behaviors['switch'].onSwitchOn;

wFORMS.behaviors['switch'].onSwitchOn = function(element)
{
// clear field values
wFORMS.helpers.enableFieldValues(element);
// run any other existing handler
if (_onSwitchOn) _onSwitchOn(element);
}
}();

/**
* Helper method to disable field values (walking down the node tree
recursively)
* @param DOMElement the element clear
*/
wFORMS.helpers.disableFieldValues = function(element) {
if(!element) return;
switch(element.tagName) {
case "INPUT":
case "SELECT":
case "TEXTAREA":
element.disabled = true;
break;
default:
for (var i=0, l=element.childNodes.length;i<l;i
++) {
if(element.childNodes[i].nodeType==1)

wFORMS.helpers.disableFieldValues(element.childNodes[i]);
}
break;
}
if(element.form) {
// If calculation behavior is set, run it to update
dependant formulas
var b =
wFORMS.getBehaviorInstance(element.form,"calculation");
if(b) {
b.run(null,element);
}
}
}

/**
* Helper method to enable field values (walking down the node tree
recursively)
* @param DOMElement the element clear
*/
wFORMS.helpers.enableFieldValues = function(element) {
if(!element) return;
switch(element.tagName) {
case "INPUT":
case "SELECT":
case "TEXTAREA":
element.disabled = false;
break;
default:
for (var i=0, l=element.childNodes.length;i<l;i
++) {
if(element.childNodes[i].nodeType==1)

wFORMS.helpers.enableFieldValues(element.childNodes[i]);
}
break;
}
if(element.form) {
// If calculation behavior is set, run it to update
dependant formulas
var b =
wFORMS.getBehaviorInstance(element.form,"calculation");
if(b) {
b.run(null,element);
}
}
}



On Nov 3, 5:46 pm, cedsav <cedric.savar...@gmail.com> wrote:
> We left that out of v3 (the implementation in v2 was buggy).
>
> You can use this instead:http://code.google.com/p/wforms/source/browse/tags/3.0/customization/...
>
> (download a copy and include the file after loading wforms.js)
>
> This clears field values when the fields are switched off. Note that
> the fields are submitted anyway (they're just blank), so that may not
> do exactly what you need.
>
> On Nov 3, 5:32 pm, "reli...@gmail.com" <reli...@gmail.com> wrote:
>
> > I am trying to force the feature on that will not submit hidden form
> > values, i checked the 2.0 documentation and it said
>
> > wFORMS.behaviors.validation.submitSwitchedOffFields = false;
>
> > i tried adding this right below
>
> > <script type="text/javascript" src="/lib/wforms.js"></script>
>
> > and it did nothing
>
> > i even added a class="required" to one of the fields, but that
> > wouldn't
> > work either

On Nov 3, 5:46 pm, cedsav <cedric.savar...@gmail.com> wrote:
> We left that out of v3 (the implementation in v2 was buggy).
>
> You can use this instead:http://code.google.com/p/wforms/source/browse/tags/3.0/customization/...
Reply all
Reply to author
Forward
0 new messages