Forum Moderators: open

Message Too Old, No Replies

Form checking + output

code needed

         

Gero_Master

8:27 pm on Dec 26, 2005 (gmt 0)

10+ Year Member



Hello!

As you might already know, i don't know much java and i would like to have someone code a little function for me.

Form: register
field1: reg_username1
field2: reg_username2

It should do it when the textbox of field2 faces OnBlur event. It should check if the values of the boxes match. If yeas, it would set variable "userok" to "true". Else, it would set it as "false"

If possible, i would prefer php code.

adni18

10:19 pm on Jan 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP code would have to be executed when the form is submitted. I say try getting the values of the inputs with $_GET["inputname"] or $_POST["inputname"] depending on what method of form submission you're using, but yes, that should work.

milanmk

7:20 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



I can help you with JavaScript and below is the code.

<script language="javascript">

function checkvalue()
{
var userok;

if (register.reg_username2.value == register.reg_username1.value)
{
userok = true;
}
else
{
userok = false;
}

alert(userok); //remove after testing
}

</script>

<form name="register" method="POST">
<input type="text" name="reg_username1" size="20">
<br>
<input type="text" name="reg_username2" size="20" onblur="checkvalue()">
<br>
<input type="submit" value="Submit" name="submit">
</form>

Gero_Master

5:51 am on Jan 9, 2006 (gmt 0)

10+ Year Member



Im really sorry i forgot to mention... It would be great if the script would add a image after the username textbox indicating if it is correct. Is it possible?