Validate empty space

Hello

I have a textbox and a input button which will insert a mysql record, however i need to validate that textbox if its empty it shouldnt allow that button to insert any record but show a popup error.

my script :

<script Language="JavaScript">

function Blank_TextField_Validator()
{
// Check the value of the element named text_name
// from the form named text_form
if (frmContact.id.value == "")
{
// If null display and alert box
alert("Please fill in the text field.");
// Place the cursor on the field for revision
frmContact.id.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}

</script>

Form :

<form name="frmContact" id="frmContact" method="POST" action="index.php" onsubmit="return Blank_TextField_Validator()">

however its not validating or showing any error. any help?

if(frmContact.id.length <= 0) { alert("Empty Field"); //return false or do whatever; };

Hope that helps,
Red :wink:

hello thank you

but can you help me with the complete code please? or correct what is wrong with the code im using

Sponsor our Newsletter | Privacy Policy | Terms of Service