virtuexru Posted September 16, 2008 Share Posted September 16, 2008 Whats the problem here? I need the script to NOT run if the length is less then 4 characters. First part works (although it still submits the form, second part doesn't even check). function validate_form ( ) { valid = true; if (document.forms[0].elements[0].value == "Search our inventory.." ) { alert ("Please enter a search term."); valid = false; } if (document.forms[0].elements[0].string.length < 4) { alert ("Our search currently supports terms over 4 characters long."); valid = false; } return valid; } Link to comment https://forums.phpfreaks.com/topic/124545-determining-string-length/ Share on other sites More sharing options...
corbin Posted September 16, 2008 Share Posted September 16, 2008 if (document.forms[0].elements[0].string.length < 4) should be if (document.forms[0].elements[0].value.length < 4) Link to comment https://forums.phpfreaks.com/topic/124545-determining-string-length/#findComment-643303 Share on other sites More sharing options...
virtuexru Posted September 17, 2008 Author Share Posted September 17, 2008 if (document.forms[0].elements[0].string.length < 4) should be if (document.forms[0].elements[0].value.length < 4) Tried it. Still doesn't work, lets the form go. Link to comment https://forums.phpfreaks.com/topic/124545-determining-string-length/#findComment-643725 Share on other sites More sharing options...
virtuexru Posted September 17, 2008 Author Share Posted September 17, 2008 Any other thoughts? Link to comment https://forums.phpfreaks.com/topic/124545-determining-string-length/#findComment-644109 Share on other sites More sharing options...
corbin Posted September 17, 2008 Share Posted September 17, 2008 I think we need more code.... Link to comment https://forums.phpfreaks.com/topic/124545-determining-string-length/#findComment-644189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.