html5 oninvalid doesn't work after fixed the input field

前端 未结 5 1636
故里飘歌
故里飘歌 2020-12-06 01:08

I have this input code in my form:



        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 02:10

    If you setCustomValidity to any value that is not the empty string then that will cause the input to be in the invalid state. So your condition is checking for a value, then setting the field to be invalid either way. Only setCustomValidity when the value in the field is actually invalid, otherwise set it to an empty string:

    
    

提交回复
热议问题