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(String(email).toLowerCase());
}
// Should hide default
$('#outform').hide();
$('input[name=User_Email]').keyup(function(){
var isValid = $(this).is(':valid') && validateEmail($(this).val());
if (isValid)
$('#outform').show();
else
$('#outform').hide();
});
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(String(email).toLowerCase());
}
Which worked as expected, then I tried this which I can’t get to work:
<script>
if $('input[name=User_Email]').is(':valid') {
$('#outform').show();
else
$('#outform').hide();
}
</script>
If anyone could help me udnerstand this isn’t hitting the .is(‘:valid’) clause it would be much appriciated.
Comments
Comment posted by isherwood
Please format (indent) your code properly. It’s a courtesy to your volunteers and just good practice.
Comment posted by bbowesbo
Hi, this answer rpovides the same output as what I already had, this display the rest of the from as soon as I enter any character in the field, I want it to only displat once the entire email is displayed.. So if I was to type in [email protected], the form would only show once a valid email was entered. The above answer shows the form when I enter a single character
Comment posted by Nguyễn Văn Phong
Yes,
Comment posted by Nguyễn Văn Phong
I’ve just updated my answer, please take a look @bbowesbo
Comment posted by bbowesbo
This is closer, how would we change it so the form dosent show on the second string, after the @ and only after the ‘.’, the above shows on use[email protected] – the desired out put would be to show from [email protected].