Murali Kris

Murali Kris

  • 1.5k
  • 254
  • 48k

RequiredField Validation controls then execute TextChanged

Aug 6 2019 6:18 AM
Hi Folks,
 
I have a webForm.aspx, it have textboxes, textbox is assosiated with fieldRequired validate control(RegularExpressionValidator,ReqiredFiledValidator) for general validations.
 but here i also required TextBox_TextChanged event for other validation so issue 
 
textbox_TextChanged event is executing before fieldRequiredvalidate controls(RegularExpressionValidator,ReqiredFiledValidator)
 
how to validate first  fieldRequiredvalidate controls if everything fine then allow to execute textBox_Textchanged even.
i just googled  and find blow link 
 https://forums.asp.net/t/1178403.aspx?How+to+stop+Textchanged+event+when+validator+is+fired+
 
my code.cs 
 
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if(!System.Text.RegularExpressions.Regex.IsMatch(TextBox1.Text,RegularExpressionValidator1))
{
Label2.Text = "from textChanged.";
}
}
 
error is: Can`t convert argument2 etc... 
Note: TextBox is validating with two Required control(regularExpression,fieldRequired) 
 
 
=> IsMatch(TextBox1.Text,Regular_Expression))
how to pass Regular_Expression..? or use regular_expression with RequiredFields Controls
 
please check above link for more details
 
 
 

Answers (3)