HTML5 - 如何设置setCustomValidity?

时间:2014-01-27 11:43:27

标签: javascript jquery html html5

如何解决输入字段以设置setCustomValidity?它不起作用:

js fiddle

$('#numberinput').val("").setCustomValidity('The two email addresses must match.');

1 个答案:

答案 0 :(得分:18)

使用jQuery,您可以执行以下操作:

$('#numberinput').get(0).setCustomValidity('The two email addresses must match.');

而不是:

$('#numberinput').val("").setCustomValidity('The two email addresses must match.');