Skip to content

Instantly share code, notes, and snippets.

@enopanen
Created December 3, 2013 18:10
Show Gist options
  • Save enopanen/7774377 to your computer and use it in GitHub Desktop.
Save enopanen/7774377 to your computer and use it in GitHub Desktop.
<!-- jQuery: Validating an email. -->
$('#txtEmail').blur(function(e) {
var sEmail = $('#txtEmail').val();
if ($.trim(sEmail).length == 0) {
alert('Please enter valid email address');
e.preventDefault();
}
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]
{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(sEmail)) {
alert('Valid Email');
}
else {
alert('Invalid Email');
e.preventDefault();
}
});
<!-- HTML: Validating an email-->
<asp:TextBox id="txtEmail" runat="server" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment