I have read in the forum several ways to handle calling 2 functions but nothing works for me (it just simply be syntax).
I have a function that verifies something was entered in a form field:
I have another function that verifies the entry was a number if the field has data entered:
I don't think I can combine them because I have some form fields that just use 1 function and other fields that just use the other function. Now I have a field which needs to use both. When I use
OR
each works great.
I've tried each of the following with no luck:
-
-
-
JS is so frustrating! Please help!
Thanks,
Jen
I have a function that verifies something was entered in a form field:
Code:
function hasValue(form_obj) {
var myVar = form_obj.value;
if (myVar == "") {
alert("This field cannot be left emtpy.");
return false;
form_obj.focus();
}
}
I have another function that verifies the entry was a number if the field has data entered:
Code:
function isNumber(form_obj) {
var myValue = form_obj.value;
if (myValue != "")
{
if (isNaN(myValue) || (myValue < 1)) {
alert("Please enter an integer greater than 1");
return false;
form_obj.focus();
}
}
}
I don't think I can combine them because I have some form fields that just use 1 function and other fields that just use the other function. Now I have a field which needs to use both. When I use
Code:
onchange="return hasValue(this)"
Code:
onchange="return isNumber(this)"
I've tried each of the following with no luck:
-
Code:
onchange="return hasValue(this); return isNumber(this)"
Code:
onchange="return hasValue(this); isNumber(this)"
Code:
onchange="a=hasValue(this); b=isNumber(this); return a && b"
JS is so frustrating! Please help!
Thanks,
Jen