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; } Quote Link to comment 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) Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
virtuexru Posted September 17, 2008 Author Share Posted September 17, 2008 Any other thoughts? Quote Link to comment Share on other sites More sharing options...
corbin Posted September 17, 2008 Share Posted September 17, 2008 I think we need more code.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.