D
David
I'm having trouble getting the regular expression validator to work
with a text box.
In this simple example I only want lower case letters to be allowed.
So I tried the following and it doesn't work, would somebody be so
kind as to tell me why.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1"
runat="server"
ErrorMessage="RegularExpressionValidator"
ControlToValidate="TextBox1"
ValidationExpression="[a-z]"></asp:RegularExpressionValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Response.Write("Page is valid");
}
else
{
Response.Write("Page is not valid");
}
}
with a text box.
In this simple example I only want lower case letters to be allowed.
So I tried the following and it doesn't work, would somebody be so
kind as to tell me why.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1"
runat="server"
ErrorMessage="RegularExpressionValidator"
ControlToValidate="TextBox1"
ValidationExpression="[a-z]"></asp:RegularExpressionValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Response.Write("Page is valid");
}
else
{
Response.Write("Page is not valid");
}
}