I have a form which allows only for numbers to be entered in the text box, or an alert appears:
<form name="formName" action="" method="post" OnSubmit="return chkSubmit();">
Input Number
<input type="text" name="txtNumber" value="">
<input type="submit" name="btnSubmit" value="Submit">
</form>
with the following javascript:
<script>
function chkSubmit()
{
if(isNaN(document.formName.txtNumber.value))
{
alert('Please input numbers only.');
return false;
}
}</script>
How do I allow for only 4 characters to be entered? No alert, just prevent the user from typing more than 4 characters.