this will not work on change. also the innerhtml wont display. please help. here is the js:

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

and here is the html: Re-type Email: <input type='text' class='rfield' name='emailcheck' id='emailcheck' onchange='checkemail()'></td><td style='position: relative;'><div id='wm' style=' font-size: 11PX; position: relative;'></div>

Recommended Answers

If innerHTML doesn't display, it may mean that your JavaScript has stopped working internally. What browser are you using? Is this the only script you have on the page? Only partial code of the page won't help...

Jump to Post

All 4 Replies

If innerHTML doesn't display, it may mean that your JavaScript has stopped working internally. What browser are you using? Is this the only script you have on the page? Only partial code of the page won't help...

Take a look at the code

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

You have an 'is equal to' instead of an equal to (=). Make this change and you should be OK.

and the on change wouldnt work, so i just changed it to onkeyup

You can use onblur or onfocus, onchange is for select box.

Be a part of the DaniWeb community

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