hi -
trying to simply validate a text box entry (fieldname: qty) on form submit. if it's not numeric, throw an alert. but of course it isn't working and i can't see why. it's throwing the alert whether the entry is valid or not.
here's the code: (ignore pcount and scount...they're always correctly filled by other means)
trying to simply validate a text box entry (fieldname: qty) on form submit. if it's not numeric, throw an alert. but of course it isn't working and i can't see why. it's throwing the alert whether the entry is valid or not.
here's the code: (ignore pcount and scount...they're always correctly filled by other means)
Code:
function isblank(s) {
for(var i = 0; i < s.length; i++) {
var c = s.charAt(i);
if ((c != ' ') && (c != '\n') && (c != '')) return false;
}
return true;
}
function validate(f) {
var msg1 = "Message!"
var q = parseInt(f.qty.value);
if ( (f.pcount.value == "") || (f.scount.value == "") || (isblank(q)) || (isNAN(q)) ){
alert(msg1);
return false;
}
return true;
}