How can I rewrite the ErrorMessage for a CustomValidator control on the client?

前端 未结 9 1313
鱼传尺愫
鱼传尺愫 2020-12-11 05:45

I have a CustomValidator that is validating a telephone number for several different telephone numbering schemes. The client-side javascript looks like this:



        
9条回答
  •  伪装坚强ぢ
    2020-12-11 05:58

    Just remove all instances of Text and ErrorMessage in the custom validator tag definitions then use

    $(#id_of_custom_validation_control).text("custom error message");
    

    Then with this, you can use one custom validator control and handle multiple error conditions

    E.g

    if(error1){
      $(#id_of_custom_validation_control).text("custom error message1");
    }else $(#id_of_custom_validation_control).text("custom error message2");
    

    Hope this helps

提交回复
热议问题