Jump to content

Registration Javascript


drexx
 Share

Recommended Posts

Hi again mates,I want to make a registration helper like we have here in this forum.Every time you click/go out of the box, it:1. See if it has between 1 and 15 characters.2. If (1.) is true then see if that name is not already in use.3. If there are no errors display "correct" after that text field, if there is any error display the error after that text field.Another thing i was looking for is the use of "disable" in forms, that way I could use disable in the form.If all the required fields have a correct after it, then change that disable to "".That button would change from, "not able to register since you don't have all the fields correctly filled" to "everything seems ok, you may register".1st problem: I don't know which is the click/go out of the box option, i'm using KeyUp.2nd problem: I don't understand javascript and I'm having lots of problems. (I already looked at JS tutorials here in W3Schools, but still don't know how to make it work).Right now I only have been trying to make the box field validation javascript, which is the worst part.The first thing you will notice is that I really don't understand a thing about JS. :)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><script type="text/javascript">function validate_form(name){	if (name==null||name=="")	{		var var_name="false";		setCookie('field_name',var_name,365);		return false;	}	else	{		var var_name="true";		setCookie('field_name',var_name,365);		return true;	}}</script></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css" /></head><body><form action="test2.php" onKeyUp="return validate_form(name)" onsubmit="return validate_form(name)" method="post"><br />Email: <input type="text" name="name" size="30"> <?phpif ( isset( $_COOKIE['field_name'] ) ) {	if ( $_COOKIE['field_name'] == "false" ) {		echo "<img src=\"/Imagens/false.png\" alt=\"false\" /> ";		echo "This name is not valid.";	}	if ( $_COOKIE['field_name'] == "true" ) {		echo "<img src=\"/Imagens/true.png\" alt=\"false\" /> ";	}}?><br /><input type="submit" value="Submit"></form></body></html>

thank you for your patience :)

Edited by drexx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...