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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check field has 1st 5 chars entered

Status
Not open for further replies.

JSMITH242B

Programmer
Mar 7, 2003
352
GB
How can I check that a field has the first 5 characters entered?

TIA
 
If you mean that you want to check if a field has at least 5 characters in it, this would work:

Code:
if (document.forms['yourFormName'].elements['yourFieldName'].value.length < 5) alert('You need to enter at least 5 characters!');

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Cheers Dan.
I did use this in the end.

It was strange that the .length property did not come up on the intellisense which confused me so I ended up doing the following

var Results = document.myform.fieldname.value
var Results2 = results.length


then I used if results < 5 ...

Thanks all the same!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top