Dec 8, 2005 #1 JSMITH242B Programmer Joined Mar 7, 2003 Messages 352 Location GB How can I check that a field has the first 5 characters entered? TIA
Dec 9, 2005 #2 BillyRayPreachersSon Programmer Joined Dec 8, 2003 Messages 17,047 Location GB 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 http://www.codecouch.com/dan/[/tt] Upvote 0 Downvote
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 http://www.codecouch.com/dan/[/tt]
Dec 9, 2005 Thread starter #3 JSMITH242B Programmer Joined Mar 7, 2003 Messages 352 Location GB 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!! Upvote 0 Downvote
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!!