Skip to content

Instantly share code, notes, and snippets.

@krutz27
Created October 4, 2013 13:37
Show Gist options
  • Select an option

  • Save krutz27/6826067 to your computer and use it in GitHub Desktop.

Select an option

Save krutz27/6826067 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" />
<!-- jQuery: Limiting MaLength for TextArea -->
var MaxLength = 500;
$('#txtDescription').keypress(function(e)
{
if ($(this).val().length >= MaxLength) {
e.preventDefault();}
});
<!-- HTML: Limiting MaLength for TextArea-->
<asp:TextBox ID="txtDescription" runat="server"
TextMode="MultiLine" Columns="50" Rows="5"></asp:TextBox>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment