RE: [PHP] validating form data...
hi miles , this should work for you! if (!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$", $email)) { echo " Please go back and fill in a VALID e-mail address exit; } thanks simba -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: 22 October 2001 14:36 To: [EMAIL PROTECTED] Subject: Re: [PHP] validating form data... Divide and conquer Have you tried it one function at a time -- e.g. if (email_is_valid($Email) { do stuff ... also, what values do these tests return? have you echoed the values? HTH - Miles At 02:07 PM 10/22/01 +0200, Toke Herkild wrote: >I've made a script which ought to validate if there is data in the fields or >not... but it doesn't seem to work... > >the validation is following: >if ((email_is_valid($Email)) and ($Name != "") and ($Message != "")){ > do stuff ... >} > >But even if I submit an empty form it executes "do stuf..." >I have tried to put an empty space into the $Name and $Message test but that >doesn't seem to do any difference either... > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.282 / Virus Database: 150 - Release Date: 25/09/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.282 / Virus Database: 150 - Release Date: 25/09/01 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] validating form data...
Divide and conquer Have you tried it one function at a time -- e.g. if (email_is_valid($Email) { do stuff ... also, what values do these tests return? have you echoed the values? HTH - Miles At 02:07 PM 10/22/01 +0200, Toke Herkild wrote: >I've made a script which ought to validate if there is data in the fields or >not... but it doesn't seem to work... > >the validation is following: >if ((email_is_valid($Email)) and ($Name != "") and ($Message != "")){ > do stuff ... >} > >But even if I submit an empty form it executes "do stuf..." >I have tried to put an empty space into the $Name and $Message test but that >doesn't seem to do any difference either... > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] validating form data...
&& and "and" are same except that they stay at different levels in the precedence table. But if the programmer is skilled he will never write code which depends on the precedence table but put brackets here and there, everywhere they are needed. -- Andrey Hristov Web Developer Icygen Corporation BUILDING SOLUTIONS http://www.icygen.com On Monday 22 October 2001 08:19 am, you wrote: > hellorghh !!! > > I think that : > > if ((email_is_valid($Email)) && ($Name != "") && ($Message != "")){ >do stuff ... > } > > ...should be better . (&&, not "and") > > > "Toke Herkild" <[EMAIL PROTECTED]> a écrit dans le message news: > [EMAIL PROTECTED] > > > I've made a script which ought to validate if there is data in the fields > > or > > > not... but it doesn't seem to work... > > > > the validation is following: > > if ((email_is_valid($Email)) and ($Name != "") and ($Message != "")){ > > do stuff ... > > } > > > > But even if I submit an empty form it executes "do stuf..." > > I have tried to put an empty space into the $Name and $Message test but > > that > > > doesn't seem to do any difference either... > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > (°-Nayco. > //\[EMAIL PROTECTED] > v_/_http://nayco.free.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] validating form data...
Nope, wasn't that... And it should not do any difference using 'and', 'AND' or '&&' as they do the same thing... Nicolas Costes : > hellorghh !!! > > I think that : > > if ((email_is_valid($Email)) && ($Name != "") && ($Message != "")){ >do stuff ... > } > > ...should be better . (&&, not "and") > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
re: [PHP] validating form data...
hellorghh !!! I think that : if ((email_is_valid($Email)) && ($Name != "") && ($Message != "")){ do stuff ... } ...should be better . (&&, not "and") "Toke Herkild" <[EMAIL PROTECTED]> a écrit dans le message news: [EMAIL PROTECTED] > I've made a script which ought to validate if there is data in the fields or > not... but it doesn't seem to work... > > the validation is following: > if ((email_is_valid($Email)) and ($Name != "") and ($Message != "")){ > do stuff ... > } > > But even if I submit an empty form it executes "do stuf..." > I have tried to put an empty space into the $Name and $Message test but that > doesn't seem to do any difference either... > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > (°-Nayco. //\[EMAIL PROTECTED] v_/_http://nayco.free.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] validating form data via javaScript when stored in an array
I don't think you can name variables as varname[name] and access them like that in javascript unless varname[name] is initialize where varname is an array and name=index in that array and it must be defined first. I believe you will have to change the naming convention from var[keyname] to var_keyname or something, and same for reading it from PHP. or else name them as: input_1 input_2 input_... input_N then you can access them in JavaScript as: for (i=0;i hope it helps. -elias http://www.kameelah.org/eassoft "Joseph Blythe" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > G'day, > > I was wondering if anyone knows how to get the following to work: > > --snip from head-- > > //--> > function validateForm(theForm) { >if ( theForm.input[name].value == "" ) { >alert("You must type a value for NAME."); >theForm.input[name].focus(); >return false; >} > > } > input = new Array(); function validateForm(theForm) { if ( theForm.input[name].value == "" ) { alert("You must type a value for NAME."); theForm.input[name].focus(); return false; } }