Board Logo

Validation not working consistently
ThrashCardiom - 8/3/2007 at 06:35 PM

I have several forms that I am using the Form Validator on but I cannot get it to work consistently. One form has four fields on it and validates correctly. I have two forms with one field each to be validated and it doesn't work at all.

All the forms are generated from a database using the same perl function and I can't see any point of difference. The code for one that doesn't work is as follows (without complete HTML tags):

form name="Provider" action="http://xxx.xxx.xxx.xxx/cgi-bin/addcpd.cgi" method="post"

td class="heading" valign="top" width="25%" id="f_400">Provider Name</

td class="field"><input type="text" name="ProviderName" id="400" size="50" maxlength="" value="" ></td

script>
var a_fields = { 'ProviderName': { 'l':'Provider Name', 'r':'true', 'f':'alpha', 't':'f_400'}
},

o_config = {
'to_disable': ['Submit','Reset'],
'alert' : 1 + 4
}
var v = new validator('Provider',a_fields, o_config);
</script

input type="submit" name="Submit" value="Submit"
input type="reset" name="Reset" value="Reset"

Can anyone see what I am doing wrong?

Thanks


tigra - 8/4/2007 at 05:07 PM

when it doesn't work what do you get? error by the validator? JavaScript error in browser? form submits without validation?

PS: just in case I'd avoid numeric IDs such as id="400"


ThrashCardiom - 8/6/2007 at 03:41 PM

The form gets submitted without validation.

Avoiding numeric ids would be a problem as the form information is pulled from a DB and the id is a key used in other aspects of the program.


tigra - 8/6/2007 at 04:24 PM

There must be some error message that you miss because of the page reload. Try to run v.exec() outside of the onsubmit (i.e. temporarily add another button and run v.exec() on its onclick)

re. IDs. Just add something in front of number i.e. id="e400"


ThrashCardiom - 8/6/2007 at 04:58 PM

Interesting. The validation works. It would appear that the validation routine is not being called when the form is submitted.


ThrashCardiom - 8/6/2007 at 05:05 PM

Found the problem. Fairly stupid really. I failed to put the onsubmit="return v.exec() line into the javascript field for the form in the database.

Thanks


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/