Trigger a button click with jQuery when enter button click -
this jquery code of mine.instead of using proceed button when click on enter remaining text boxes should display
$("#btnvalidatemember").click(function () { if ($("#txtuseremail").val() == "") { $("#txtuseremail").addclass("error"); //$("#spnuseremail").text("required"); } else if($("#spnuseremail").text() == "") { getmemberdetailsbasedonemailid($("#txtuseremail").val()); } $("#ddlbusinessstate").empty().append($("<option/>")); //$("#ddlbusinesscity").empty().append($("<option/>")); $("#ddlbusinessstate").select2({ placeholder: 'state', allowclear: false }); //$("#ddlbusinesscity").select2({ placeholder: 'city', allowclear: false, width: '366px' }); bindstatesbasedoncountryid("1",`enter code here` "ddlbusinessstate", "");enter code here });
please see jsbin
$(document).keypress(function(e) { if(e.which == 13) { $('#btnvalidatemember').trigger('click'); } });
above jquery
code detect keypress event if have pressed enter button trigger click event of #btnvalidatemember
button.
Comments
Post a Comment