I agree with Roel for the most part. The portability of JS really isnt an issue in form validation, since virtually all of the JS you use is both MS and NN compatible. The big disadvantage to JS, is of course if the user has it turned off. Then the validation never occurs, and you could end up with a mess in the DB. But the advantages are just as Roel said.
This is the kind of code I use for validation:
<head>
function validate(form){
if (form.fieldname.value==""){
alert('you must fill out field fieldname');
form.fieldname.focus();
return false;
}
if(isNaN(form.fieldname2.value)){
//isNaN stands for is Not a Number
alert('you must fill out field fieldname2');
form.fieldname2.focus();
return false;
}
return true;
}
</head>
......
......
other stuff here
......
<form name = "frmnamewhatever" action="yadda.html" method = "post">
<input type = "text" name = "fieldname" value = "">
<input type = "text" name = "fieldname2" value = "">
<input type = "submit" name = "submit" value = "Submit" onClick="javascript: return validate(frmnamewhatever);">
</form>
Hope this does the trick. I wont guarentee the above JS, but Im pretty sure it should do the trick
Good luck!
Darren