So I am trying to submit the form through jQuery onblur (i.e. As soon as the focus leaves the password field, form submits through jQuery). There are similar questions but it's not what I am looking for. I tried using the document.getElementById but it isn't working.
Any help is appreciated. Thanks in advance.
<script>
$(function(){
$("#pswd").blur({
$("#myForm").submit();
});
});
</script>
As @dvenkatsagar suggested, you have some syntax errors,
Live Preview: http://codepen.io/larryjoelane/pen/VedXqr
(function($){
//I selected the body tag first because I do not know if you are creating
//the pswd element dynamically
$("body").on("blur","#pswd",function(e){
$("#myForm").submit();
});
})(jQuery);
It is not necessary but I changed the way your closure was structured just in case you want to use other libraries in the future inside your closure besides jQuery.
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