Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

regular expression that does not accept empty filed or white spaces but only letters

$
0
0

I've added some asp:RegularExpressionValidator to my textboxes and the client needs to fill these textboxes and submit the result into a database but the problem is that I have:

<table style="position:relative; z-index:2; ">         <tr>                                <td><asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="X-Large"  >FirstName :</asp:Label> </td><td><asp:TextBox ID="TextBox1" runat="server" style="width:auto;"></asp:TextBox></td><td><asp:Label ID="Label2" runat="server" Font-Bold="true" Font-Size="X-Large" >LastName :</asp:Label> </td><td><asp:TextBox ID="TextBox2" runat="server" style="width:auto;"></asp:TextBox></td></tr><tr><td><asp:RegularExpressionValidator Font-Size="Large" ForeColor="Red" ControlToValidate="TextBox1" ID="RegularExpressionValidator1" runat="server" ErrorMessage="Firstname must contain only letters" ValidationExpression="^[A-Za-z]*$"></asp:RegularExpressionValidator></td><td>&nbsp</td><td><asp:RegularExpressionValidator Font-Size="Large" ForeColor="Red" ControlToValidate="TextBox2" ID="RegularExpressionValidator2" runat="server" ErrorMessage="Lastname must contain only letters" ValidationExpression="^[A-Za-z]*$"></asp:RegularExpressionValidator></td><td>&nbsp</td></tr>

and if the client left the fields empty or added some white spaces he will be able to submit his response.  I need to stop this and I tried with regular expression validator but that didn't work and I didn't know how to use the custom validator it just didn't fire...

Any HELP plz!!


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>