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

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).

do i need to use any ajax?

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.

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>

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.

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!';
}
}
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.