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
Form validation
Moderator: General Moderators
Weirdan | Please use
Weirdan | Please use
Code: Select all
andCode: 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.Code: Select all
andCode: 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]