I have a form with one multiline textbox, one button and two validators.
I have the following markup:
<asp:RequiredFieldValidator ID="vldQuestionTextRequired" runat="server" ControlToValidate="tbmQuestionText"
Display="Dynamic"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="vldNotHintText" runat="server" ControlToValidate="tbmQuestionText"
Display="Dynamic" EnableClientScript="true" OnServerValidate="HintText_ServerValidate"
ClientValidationFunction="HintText_ClientValidate"></asp:CustomValidator>
<span class="eq_ad_question_field_bg"> </span>
<asp:TextBox ID="tbmQuestionText" runat="server" CssClass="eq_ad_question_field"
TextMode="MultiLine"></asp:TextBox>
The client side validation JS looks like this:
function HintText_ClientValidate(sender, e)
{
if(e.Value != null)
e.IsValid = e.Value != '<%= InstructionalText %>';
else
e.IsValid = false;
}
When I click the button without modifying the original hint text I get the correct validator error message, and the focus goes back to the textbox. If I then write something in the textbox and then click the button, the validator gets reevaluated and disapears, but no postback happens. If I click the button again, I get the postback.
Has any one seen this behavior before?
Thank you!
Edit: I found that if I make the validators static instead of dynamic, the button works. Is there any way to get around this?
Well this textbox had some javascript to make it elastic. This javascript fiered on the onblur event in order to remove unsused space, and since the textbox was changing, the postback was stopped. The minimization of the textbox was not a requirement to begin with, so I removed it and the postback worked great.