Re: validate form with javascript

From: Date: Mon, 14 May 2001 03:06:53 +0000
Subject: Re: validate form with javascript
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52645@lists.php.net to get a copy of this message
What is the particular error you're getting? ""Chris Mason"" <chris@net.ai> wrote in message news:HEEGJMGDMPHCBLNLINLKEEMADDAA.chris@net.ai... > I have a form in which I validate the email address using a php function > then alert the operson if the email address is not correct. However, I would > like to pop up an alert with javascript if the email field is left blank. I > am using the function below but it down't work with php, probably works > great with a cgi. > > Does anyone have a better way to do this? > > Chris Mason > Code: > in the head > > function validForm(replyForm) > { > if(replyForm.email.value==\"\"){ > alert(\"You must enter an email address\") > replyform.email.value.focus() > return false > } > return true > } > > > in the form: > <FORM onSubmit=\"return validForm(this)\" METHOD=\"POST\" > ACTION=\"reserve.php3?action=send\" ENCTYPE=\"x-www-form-urlencoded\"> > <table> > <TR CLASS=\"$c\"> <TD CLASS=\"$c\">E-Mail </TD> <TD > COLSPAN=\"$i\"><INPUT > TYPE=\"text\" NAME=\"email\" VALUE=\"$email\" > SIZE=\"50\"></TD></TR> > > </table> > </form> > ") > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#52645) next »