Wednesday, 7 August 2013

RegularExpressionValidator is not working

RegularExpressionValidator is not working

I'm total newbie in using asp.net and I have this regular expression
validator that was working perfectly fine before but after I made a huge
edit to my textboxes its not working anymore.
In before edit, when I try to submit the form, if my textbox is empty or
the value = "" it will show the error message and will NOT redirect to
another page.
In after edit, when I try to submit the form, whether the textbox is empty
or not it will redirect to another page. Not stopping the page from
redirecting or showing the validator
before edit.
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" Text="Enter Value Here" OnClick="this.value=''"
onblur="tryPlaceholder(this,'Enter Value Here')" ></asp:TextBox>
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)" Runat="server"/>
after edit
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" onblur="tryPlaceholder(this);"></asp:TextBox>&nbsp;
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)"
runat="server"/>&nbsp;</td>
Please help!

No comments:

Post a Comment