0

i am making a register page on my website. i have a password and a re-enter password text fields. how would i validate those two by making sure they are the same in ajax? and how would i make that happen on the re-enters onblur or onchange?
thank you

3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by kardklub
0

You just need JavaScript to validate the text field value. Yes, using onchange would be the best. Do not use onblur because it is very difficult to control and could give you an unexpected result (unwanted running of javascript).

0

You don't need to use Ajax. :) However, you could use Ajax if you want. By the way, you would need Ajax if you need to retrieve data from the server (such as read from database). Validate current value on the page does not require Ajax.

0

this code wont work:

function checkemail(){
if (document.suform.email.value == document.suform.emailcheck.value)
{
document.suform.emailcheck.style.backgroundColor='#F75B53';
document.getElementById('wm').innerHTML=='Emails do not match';
}
<input type='text' class='rfield' name='emailcheck' id='emailcheck' onchange='checkemail();'></td><td><span id='wm' style='color: red; font-size: 11PX;'></span>
0

Hmm... Translate your code..
Line 2: If the email and the emailcheck values are the same
Line 3: then color the emailcheck field
Line 4: display "Emails do not match" in wm field

Are you sure that it is what you want for the condition if-statement? :)

By the way, I would add a check to see if the email field contains valid email format.

Edited by Taywin: n/a

0

i have this code and it still wont work:

function checkemail(){
if (document.suform.email.value && document.suform.emailcheck.value)
{
if (document.suform.email.value == document.suform.emailcheck.value)
{
document.getElementById('wm').innerHTML=='Emails Match!';
}else{
document.suform.emailcheck.style.backgroundColor='#F75B53';
document.getElementById('wm').innerHTML=='Emails Dont Match!';
}
}
}
0

Could you show me the script & form part in a page? You could display other portion as ... so you don't need to show the whole page code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.