I'm trying to do a validation in an email field, I even "can" do, but it's not 100% functional, I'd like to cancel the button with the disabled attribute until the user places a valid email , I get the button to cancel, but when I type the correct email it does not come back.
Input and button
<div>
<input value="Digite seu e-mail" onclick="this.value=='Digite seu e-mail'?this.value='':''" onblur="this.value==''?this.value='Digite seu e-mail':''" type="text" name="email" id="newsletter" title="Assine nossa newsletter" class="input-text required-entry validate-email input-news validatex"/>
</div>
<button type="submit" class="button btn-inline news-button" id="validatex"><span>Enviar</span></button>
Function
function validateEmail(email) {
var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validatex() {
if (validateEmail(email)) {
$j('#validatex').removeAttr('disabled');
$j("#newsletter").css("background", "none");
return true;
} else {
$j("#newsletter").css("background", "url(../../skin/frontend/ultimo/default/images/icon-erro.png) no-repeat 330px #fff");
$j('#validatex').attr('disabled', 'disabled');
return false;
}
}
$j(".validatex").bind("blur", validatex);
$j("#validatex").bind("click", validatex);