[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

RegularExpressionValidator not working?

Posted on 2014-03-01
2
Medium Priority
?
174 Views
Last Modified: 2014-03-10
Hi all,

I have the following code;

    <asp:TextBox ID="UsernameTextbox" runat="server" MaxLength="10" ></asp:TextBox>

    <asp:RegularExpressionValidator id="UsernameRegularExpressionValidator" runat="server" 
        ValidationExpression="[0-9a-zA-Z]" 
        ControlToValidate="UsernameTextbox" />

Open in new window


I want to restrict special chars from being entered to my textbox. However, it is still allowing me to enter these? I only want the user to be able to enter alphanumeric values.

Now I am capturing the .keyup() method using Jquery, coudl this be causing a problem?
0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 2000 total points
ID: 39897915
See http://msdn.microsoft.com/en-us/library/ff650303.aspx

Your expression will validate true as long as there is at least one alphanumeric.

You need to validate true only if all characters are alphanumeric:

    ValidationExpression="^[0-9a-zA-Z]*$"

Gary Davis
0
 

Author Comment

by:flynny
ID: 39898406
Hi Gary

Many thanks for the reply and the Regex update.

I've been reading up on the validator. Does the validator check input as the user types (I.e. Restrict client side?) or when I submit serverside?

The reason I ask is I am performing a Ajax (using jquery) call to a webmethod which he is the db to see if the username exists. Therefore at the moment it is allowing user to type the illegal char and sending to the webmethod?

Will I need to do a jquery check on the key up event and double check in the webmethod?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question