|
-
February 1st, 2006, 10:25 PM
#3
Here's a very generic one I wrote. Should work for any form. If you don't need the passwords matching, you can remove that. The -2 in the test assumes you have 2 buttons, submit and reset.
function check_form() {
var frm = document.forms[0];
var message="";
var x=0;
{
for(var i=0;i< (frm.elements.length-2);i++) {
if((frm.elements[i].value == "") || (frm.elements[i].value == null)) {
if(x==5){
message += "\n";
}
message += frm.elements[i].getAttribute('name') + ', ';
x++;
}
}
if(x!=0){
alert("The following required fields: "+message+" were left blank");
frm.elements[i-x].focus();
return false;
}
if(frm.elements[1].value!=frm.elements[2].value) {
alert('The Passwords Do Not Match');
return false;
}
else {
return true;
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|