The best way to do this is to use the enter button and click the button without a headache to write js check for each input you enter, if the user presses the enter button or not, it uses the input type submit
.
But you would run into the problem that onsubmit
would not work with asp.net.
I decided it very easily.
if we have this form
<form method="post" name="setting-form" > <input type="text" id="UserName" name="UserName" value="" placeholder="user name" > <input type="password" id="Password" name="password" value="" placeholder="password" > <div id="remember" class="checkbox"> <label>remember me</label> <asp:CheckBox ID="RememberMe" runat="server" /> </div> <input type="submit" value="login" id="login-btn"/> </form>
Now you can catch this event before submitting the form and stop it from postback and do whatever ajax you want using this jquery.
$(document).ready(function () { $("#login-btn").click(function (event) { event.preventDefault(); alert("do what ever you want"); }); });
shady sherif
source share