changing the language of error message in required field in html5 contact form

后端 未结 9 948

I am trying to change the language of the error message in the html5 form field.

I have this code:



        
9条回答
  •  情话喂你
    2020-11-27 13:43

    setCustomValidity's purpose is not just to set the validation message, it itself marks the field as invalid. It allows you to write custom validation checks which aren't natively supported.

    You have two possible ways to set a custom message, an easy one that does not involve Javascript and one that does.

    The easiest way is to simply use the title attribute on the input element - its content is displayed together with the standard browser message.

    
    

    enter image description here

    If you want only your custom message to be displayed, a bit of Javascript is required. I have provided both examples for you in this fiddle.

提交回复
热议问题