Page 1 of 1

Form validation

Posted: Mon Oct 31, 2005 1:41 am
by eshban
Hi , i have a simple, i want to apply a validation so that user cannot cannot leave any field blank.

means when user press the submit button, the form will transfer the control back, and highligh the text or anything which shows, that "that field" is missing.

how can i do that

plz reply

eshban

Posted: Mon Oct 31, 2005 2:05 am
by mickd
Weirdan | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
easy way is to have the form go back to the same page and have the validation code in the same page at the top

other way is to use sessions to store the data check it and then display it back.

Code: Select all

if(empty($_POST['fieldname'])) {
$empty = 1;
}

// form

if($empty == 1) {
echo 'field empty';
} // thats the easy concept behind it.
Weirdan | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]