I’m sure this should be easy, but I can’t get it working.
html
<label for="email">Enter email for updates:</label>
<input type="text" name="email" id="email" placeholder="your@email.com" />
<button name="submit" type="submit">Submit</button>
js
$(document).ready(function() {
$('button').hide();
$('input').keyup(function() {
if( !validateEmail(email) ){
$('button').show();
}
};
function validateEmail(email) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
return emailReg.test( email );
}
});
I’m not looking for it to be the best email validation, rather just a simple way to show users when form looks right.
Any help gratefully received.
5 problems :
"valid email"@example.com)My proposal for the first four problems :
Demonstration
For the last problem, I’d suggest you to read Stop Validating Email Addresses With Your Complex Regex.