Validating user input.

Codes here !

Moderators: egami, macek, gesf

Post Reply
lsg3385

Mon Mar 17, 2003 10:48 am

Per my previous post on using $form...All I want to do is validate the input fields are not blank..etc, to put up an error message and repaint the form by using the $form in a variable.
such as:
if ($sPass == "") :
$message="The student's Password is a required field.";
print "<p align=\"center\"><span class=\"subhead\">$message</span></p> ";
$error_flag = "y";
endif;

// If the $error_flag has been set, redisplay the form
if ($error_flag == "y") :
print "$form";

else : etc.


BUT perhaps there is a better way, and I can stop driving myself crazy getting the sql statement to run, display data in the variable. Is there another way to validate user input without going to another page?

User avatar
Redcircle
Moderator
Moderator
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Mon Mar 17, 2003 3:44 pm

You would have to use javascript.

mcandrey
New php-forum User
New php-forum User
Posts: 10
Joined: Tue Mar 25, 2003 3:59 am
Location: bucharest-romania
Contact:

Tue Mar 25, 2003 7:36 am

<script>

function vercimpx(cimpx)
{
var key=cimpx.keyCode;
if((key>47 && key<58) || (key>95 && key<106) || (key>111 && key<124) || (key==46) || (key==27) || (key==9))
return true;
else
alert("Bad value ... please insert a number here!");
return false;
}

</script>

please visit http://www.ekadou.ro

Post Reply