Link to home
Start Free TrialLog in
Avatar of souvik2008
souvik2008Flag for India

asked on

Displaying Success Message for validation control in ASP.NET

I am trying to add a success message for the correct input type in a asp text box which uses the regularexpression validator . But I could not succeed as there is an errormessage property of ASP.NET which works for me for the incorrect input but I could not found any properties or method of validation control which executes the validation of the text field and gives the result back to the user whether it is success or an error. I have tried the regualrexpressionfieldvalidator.IsValid but it also doesn't worked for me.
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

You will need to check this through coding


textReplaceResults.Text = "N/A";
      try
      {
        if (Regex.IsMatch(textSubject.Text, textRegex.Text, getRegexOptions())) {
          textResults.Text = "The regex matches part or all of the subject";
        } else {
          textResults.Text = "The regex cannot be matched in the subject";
        }
      }
      catch (Exception ex)
      {
        // Most likely cause is a syntax error in the regular expression
        textResults.Text = "Regex.IsMatch() threw an exception:\r\n" + ex.Message;
      }

Open in new window

Avatar of souvik2008

ASKER

Can you give me the full code of this . That will help me understand what are this objects are all about.
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your reply.