11

How can I address the input field to set the setCustomValidity? It does not work:

js fiddle

$('#numberinput').val("").setCustomValidity('The two email addresses must match.');
user2952265
  • 1,590
  • 7
  • 21
  • 32

1 Answers1

18

Using jQuery you could do the following:

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

And not:

$('#numberinput').val("").setCustomValidity('The two email addresses must match.');
lshettyl
  • 8,166
  • 4
  • 25
  • 31
Rajesh Dhiman
  • 1,888
  • 1
  • 17
  • 30
  • it does not seem to work: [js fiddle](http://jsfiddle.net/97A4G/) – user2952265 Jan 27 '14 at 13:07
  • 2
    It doesn't work like this, you have to call some function to validate and set your custom message. Check out the exact syntax at http://msdn.microsoft.com/en-us/library/windows/apps/hh441292.aspx – Rajesh Dhiman Jan 27 '14 at 13:21
  • 6
    Yes, this is not correct. So how come this is marked as accepted answer with lots of upvotes when this is plain wrong? – OMA May 05 '15 at 12:51