Client side validation works fine. I disabled the client side to see if it also works good server side, but fails. The compiler reaches 'SaveData' even if the input text is invalid. There are no update panels. How should I solve this.
ASPX:
<asp:TextBox ID="txtDept" runat="server" pattern="[a-z A-Z]*"></asp:TextBox>
<asp:RegularExpressionValidator
ID="revDept"
runat="server"
ValidationExpression="^[a-zA-Z\s]{1,50}$"
ControlToValidate="txtDept"
Display="Dynamic"
ErrorMessage="Only alphabets and spaces are allowed."
EnableClientScript="false">
</asp:RegularExpressionValidator>
C#:
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
SaveData();
}
}