...

View Full Version : text in textbox



sherlockturtle
09-14-2011, 11:27 PM
how would you make a function that cheks if any text is in a text box.

Old Pedant
09-15-2011, 12:56 AM
if ( document.formName.fieldName.value = "" )
{
alert("field is empty");
} else {
alert("field is not empty");
}

If you want to make sure the field has something *other* than just spaces, just strip out the spaces:


if ( document.formName.fieldName.value.replace(/\s/g,"") = "" )

sherlockturtle
09-15-2011, 01:36 AM
Thanks, i wonder why i didint think of that...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum