Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check max length of text field

Status
Not open for further replies.

dinoviapangea

Technical User
Apr 9, 2002
41
US
I know this has probably been asked before, but I still can't find the simple answer. I have a input text field that I want to validate to not go over 256 characters. Any suggestions.

Thanks
 
I actually want javascript to catch it on submission if it is over 256.
 
<script language=&quot;Javascript&quot;>
function checkEntry()
{
if(document.formname.textFieldName.value.length > 256){
alert(&quot;you have entered the maximum allowed characters&quot;);
document.formname.textFieldName.focus();
return false;
}
return true;
}
</script>

and call this function using onSubmit() or onChange() event handler.
 
before you submit the page, you call the function like this.

onSubmit=&quot;return checkEntry();&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top