I need to call reportValidity but I want to this in jquery, which is the method that replicated this logic in jquery?
For example:
$('login').submit(function(event) {
$(this).reportValidity();
});
this return:
reportValidity is not a function
It's because $(this) wraps it in a jQuery object which does not support the method reportValidity(). It must be called on the native DOM element.
In your case it would suffice to not wrap it in jQuery, just like
$('login').submit(function(event) {
this.reportValidity();
});
For clarification and adaption, this would work too:
$('login').submit(function(event) {
var $this = $(this);
$this.get(0).reportValidity();
});
.get retrieves the plain element of a jquery collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With