|
-
May 22nd, 2007, 09:46 PM
#1
Thread Starter
Member
validate number fields[help]
i want to validate a field that require the user to insert number/integer. i have come up with this code, but this code only validate when the user did not enter anything on the field.
can someone show me how to validate a field that require the user insert integer?
<script language="JavaScript">
function Form()
{
var cpos;
with(window.document.msgform)
{
cpos =postalCode;
if(cpos.value == "")
{
alert('Please enter your postalCode.Only numbers are allowed. ');
return false;
}
Else{
Return true;
}
}
}
</script>
<body>
<form name="form" method="post" onSubmit="return form()">
PostalCode:<input name="postalCode" type="text" />
<input type="submit" name="submit" value="Submit">
</form>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|