My form has a SSN field. I need to make sure that the user only enters numbers into the field.
Right now, my script checks to make sure the field is not left empty, but does not enforce numbers only. Can anyone help me with this? I'd like it to display a different message if the user enters anything other than numbers. Like, "Your social security number can only contain numbers."
Thanks,
Here's the pertinant form fields:
Here's the code for the script:
Right now, my script checks to make sure the field is not left empty, but does not enforce numbers only. Can anyone help me with this? I'd like it to display a different message if the user enters anything other than numbers. Like, "Your social security number can only contain numbers."
Thanks,
Here's the pertinant form fields:
Code:
<input type="text" name="ssn">
<input type="image" src="pics/btn_submit.gif" width="80" height="19" name="submitit" onclick="return dosubmit()">
Here's the code for the script:
Code:
function dosubmit()
{
error = "";
{
if(document.frm_page.ssn.value == "")
{
error = error + "\n" + "You must provide your social security number.";
}
if(error != "")
{
alert("----------- Error! ------------" + error);
}
else
{
document.frm_page.submit();
}
}
}