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

前端 未结 9 1327
鱼传尺愫
鱼传尺愫 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 06:09

    I think the problem is that there is no 'errormessage' property on the client side. The custom validator renders a tag to display the error message with an id corresponding the id property of the custom validator control. To set the text displayed when validation fails you need to do somthing like this.

    ... 
    case "North America":
        args.IsValid = validateNAPhoneNumber(cleanNumber);
        if (!args.IsValid) 
            document.getElementById(sender.id).innerText = "* Not a NA Phone #";
        break;
    ...
    

提交回复
热议问题