Home > ASP.Net > User RegularExpression Validator to allow user to enter English letters only

User RegularExpression Validator to allow user to enter English letters only


Hi

try this example to User RegularExpression Validator to allow user to enter English letters only

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
        ErrorMessage="Enter your name in English letters between 5 and 10 letters"
 ValidationExpression="^([a-zA-Z]{5,10})$"></asp:RegularExpressionValidator><br />
    <asp:Button ID="Button1" runat="server" Text="Button" />

if we want to remove white space from Textbox

<asp:TextBox ID="TextBox1" runat="server"
onblur="javascript:this.value=this.value.replace(/\s/g,'');"></asp:TextBox>

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net
  1. May 3, 2009 at 8:33 pm

    Hi, nice post. I have been thinking about this topic,so thanks for posting. I’ll certainly be subscribing to your posts.

  2. yasserzaid
    May 4, 2009 at 12:55 pm

    Your are welcome

    Hope my post helps you

    Good Luck 😀

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: