hi unable call submit function of jquery below html , jquery code
jquery code:
$(document).ready(function () { //global vars var username = $("#username"); //user name field var userpass = $("#password");//password field //when form submitted $("#overlay_form1").submit(function () { window.alert("please fill username & password!"); return false; }); //open popup $("#pop").click(function () { $("#overlay_form1").fadein(500); positionpopup(); }); //close popup $("#close").click(function () { $("#overlay_form1").fadeout(500); }); }); //position popup @ center of page function positionpopup() { if (!$("#overlay_form1").is(':visible')) { return; } $("#overlay_form1").css({ left : ($(window).width() - $('#overlay_form1').width()) / 2, top : ($(window).width() - $('#overlay_form1').width()) / 7, position : 'absolute' }); } //maintain popup @ center of page when browser resized $(window).bind('resize', positionpopup);
html code:
<a href="#" id="pop" >popup</a> <br /> <form id="overlay_form1" name="overlay_form" method="post" onsubmit="return false;"> <h2> put contents here..</h2> <label>username: </label><input type="text" name="username" id="username" /><br /><br /> <label>password: </label><input type="text" name="password" id="password"/><br /><br /> <input type="button" value="login" /> <a href="#" id="close" >close</a> </form>
you don't have submit button. change
<input type="button" value="login" />
to
<input type="submit" value="login" />
and should work.
Comments
Post a Comment