function isValidInt(userInput, errorMsg, isReq){
var mask=/^\d+$/;
if (isReq == false && userInput.value == "") return true;
if (mask.test(userInput.value)) return true;
return false;
}
I suspect that you need to reference the variable userInput.value by its
full name.
Here is an example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form check</title>
<script type="text/javascript">
function validate()
{
alert("in function validate.");
var submitOK = true;
// Notice how I referenced the fields in a form.
// You do not need to make a separate variable.
var theName = document.forms["myForm"].theName.value;
var theEmail = document.forms["myForm"].theEmail.value;
alert(" theName = " + theName +
" theEmail = " + theEmail);
// I changed submitOK to a boolean variable.
var submitOK = true;
// Validate email: name and email
if (theName == '')
{
alert("Please fill in your Name");
submitOK = false;
}
if (theEmail == '')
{
alert("Please fill in Email");
submitOK = false;
}
return submitOK;
}
</script>
</head>
<body>
<p>Please try out our form.</p>
<form name="myForm"
action="http://www.nonamedomain.com"
method="POST"
onsubmit="alert('checing then submitting...');return validate();">
<p>Name:<br>
<input type="text" name="theName" size="20"><br><br>
Email:<br>
<input type="text" name="theEmail" size="20"><br>
</p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
Robert