Hi everyone,
I've whipped up a simple validation script to vaildate simple form elements.
My issue is when i submit the form without any data it works correctly. It catches on each individual element and reports the error.
When the fields are populated correctly, i am receiving an error message in firebug stating that myForm is undefined.
is this something to do with the way in which getElementByID functions or is my code out of whack ?
also from this function i would like to know how i can make it return so if my button has additional function call appended to it, it will begin to function the addtional request.
<input type="button" onclick="return validateForm('myDeliveryForm'); loadnext(1,2);">
as you can see there are 2 functions being called when the button is hit... what would be required in my code below to let the browser return the next function ?
function validateForm(args,len)
{
var myForm = document.getElementById(args) ;
for( i=0 ; i<=document.getElementById(args).length ; i++ )
{
if(myForm[i].getAttribute('required') == 'true' && myForm[i].value == '')
{
alert(myForm[i].getAttribute('message'));
myForm[i].focus();
return false;
}
}
return true ;
}