killboy Posted December 27, 2007 Share Posted December 27, 2007 Hi there,I'm validating a form in JavaScript. So far, I can control that certain fields are not empty, but, can I control the data type in a particular field?For example, I want to control that a field called ID has only numeric values. Is there any method in JavaScript capable of doing that??Thanx. Link to comment Share on other sites More sharing options...
zppblood Posted December 27, 2007 Share Posted December 27, 2007 There are many ways to do that. You can use regular expressions, toString() parseInt(), or in this case of seeing what they typed is a number use isNaN() [isNotaNumber] Link to comment Share on other sites More sharing options...
killboy Posted December 27, 2007 Author Share Posted December 27, 2007 Thank you pal! Link to comment Share on other sites More sharing options...
zeeshan Posted December 31, 2007 Share Posted December 31, 2007 can u tell me how should i put up these folloing scripts please <html><head><title>Login</title></head><body><form action="login.php" method="post">Username: <input type="username" name="username" /><br/>Password: <input type="password" name="password" /><br/><input type="submit" value="Login" /></form></body></html>some people say it should be written as log in.html how should i add this to my web site ]<html>[code]this is said as log in.php i dont know how to make this think work i have put this script as login.php i dont know how can my web site be used to this <head><title>Login<title></head><body><?php$con = mysql_connect("localhost","pokemonrpg_zeeshan", "gdf gdr");if (!$con) { die('Couldnt connect to Database' ); } mysql_select_db("registered_members", $con); $result = mysql_query("SELECT * FROM registered_members"); $row = mysql_fetch_array($result); if ($_POST['Username']==$row[ 'username']&&$_POST['password']==$row[ 'Password']) echo "Login successful";elsedie('Login failed'); mysql_close($con)?></body></html> <html><head><title>Register!</title></head><body><form action="register.php" method="post">Username: <input type="text" name="Username" /><br> Password: <input type="password" name="Password" /><br> Confirm Password: <input type="password" name="ConfirmPassword" /><br> Email: <input type="text" name="Email" /><br> Confirm Email: <input type="text" name="ConfirmEmail" /><br> <input type="Submit" name="Submit" /><br> </form></body></html> the above one is said as register.php i dont know can its data will be stored to the db <html><head><title>Register!<title></head><body><?php$con = mysql_connect("localhost", "pokemonrpg_zeeshan", "tut"); if (!$con) { die('Couldnt connect to Database' ); } mysql_select_db("registered_members", $con); $email=$_POST["Email"]; $emailconf=$_POST["ConfirmEmail"]; . if ($email!==$emailconf) { die ('Emails do not match.'); } $pass=$_POST["Password"]; $confpass=$_POST["ConfirmPassword"]; if ($pass!==$confpass) { die ('Passwords do not match.'); } mysql_select_db("registered_members", $con); $res=mysql_query("SELECT * FROM registered_members where Username='".$_POST[Username]."'"); if (mysql_num_rows($res)>0) { die ('Username already taken!'); } else $sql="INSERT INTO registered_members (Username, Password, Email) VALUES ('$_POST["Username"]','$_POST[Password]','$_POST[Email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $to = "$_POST[Email]"; $subject = "Successfully Registered!"; $message = "Hello! You have successfully registered to www.pokemon.freehoxt.com! Username:$_POST[Username], Password:$_POST[Password]"; $from = "zeeshanali_syed_1993@yahoo.co.in"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Successfully Registered! Check your email!";mysql_close($con) ?></body></html> this one is beging said as register.php how should i make this thing work at my web site i need a tutorial by ulook at my web site www.pokemonrpg.freehoxt.com Link to comment Share on other sites More sharing options...
Synook Posted December 31, 2007 Share Posted December 31, 2007 You can just upload those scripts, they will operate. But please don't use them, as discussed there are many security holes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.