hey,
i have a form with 7 texboxes. i then have two functions; one to check if two of the textboxes have the same value and one to check if any of the textboxes are blank.
Heres the first one:
Heres the second one:Code:function compare(val1, val2) { if (val1 != val2) { alert("Your passwords do not match"); return false; }else{ return true; }}
Now, i then call the two functions in the 'onclick' event of the submit button by doing:Code:function checkempty() { var abc, bcd, cde, def, efg, fgh, ghi abc = document.getElementById('username'); bcd = document.getElementById('password'); cde = document.getElementById('passwordconfirm'); def = document.getElementById('emailaddress'); efg = document.getElementById('location'); fgh = document.getElementById('secretquestion'); ghi = document.getElementById('secretanswer'); if (abc.value == ''||bcd.value == ''||cde.value == ''||def.value == ''||efg.value == ''||fgh.value == ''||ghi.value == '') { alert("Not all fields contain data"); return false; }else{ return true; }}
The only thing is, only the first function is working. If there are blank textboxes the form will still submit. Can anyone see anything wrong with this as i'm tearing my hair out over itCode:onClick="return compare(form1.password.value,form1.passwordconfirm.value); return checkempty();"![]()
Thanks, BIOSTALL




Reply With Quote