Jump to content

Determining string length?


virtuexru

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.