Page 1 of 1

form validation problem - urgent plz help

Posted: Fri Apr 16, 2004 5:48 am
by gaurav_sting
hi,

i have been trying to implement the form validation, in which the user is shown error in RED (or any) color next to the textbox or any input box in the next page, if he or she does not enter or enters wrong information.

I am trying to implement the validation similar to what happens when a user registers for an account for Yahoo Mail. He/she is shown the only fields which are left out or inputted wrong.

NOTE: i am using smarty templating system.

Plz help me finding a code snippet or some tutorial.

Thanx
Gaurav

Posted: Fri Apr 16, 2004 9:58 am
by JAM
For different ways of the actual validation, regular expression would be interesting:
http://www.php.net/ereg (and eregi, preg and so on)
Also, string functions: http://www.php.net/manual/en/ref.strings.php

There are also the possability to use client side javascript to verify form inputs. It's been discussed before so you likely will find it after searching the forum some.

Tutorial or snippets... http://www.evilwalrus.com/ has some of these I'm sure.

Displaying the "Required" label next to the textbo

Posted: Fri Apr 16, 2004 6:37 pm
by sueannaberry
How do I display a label with RED "Required/Incorrect" text next to the textbox where the input is blank/incorrect?
I can validate the input in PHP but instead of doing - echo "blah-field" is not filled up/incorrect", how do I get back to the HTML form and display the labels next to all the associated textboxes?

Pls help!