javascript - Reseting form fields to initial state -
i using below code using jquery set form fields
$("#frmlogin").reset()
above code use reset fields in below form
<form name='frmlogin' method='post' id="login_form" style="margin:0 auto; margin-top:50px; width: 40%; height:300px; text-align:center;"> <input class="oformjumbo oformmed oinputtext" type="text" name="requiredlogin" placeholder="login id" autocomplete=off /> <div class="cleaner h10"></div> <input class="oformjumbo oformmed oinputtext " type="password" value="" name="password" placeholder="password" autocomplete=off onfocus="changetouppercase(document.frmlogin.requiredlogin.value);" /> <div class="cleaner h10"></div> <a href="javascript:fp();">forgot password?</a> <div class="cleaner"></div> <input style="margin-left:0px; " class="submit_btn float_l" type="button" value="sign in" name="sign in" onclick="javascript:func_get_data();"/> <input style="margin-left: 200px; " class="submit_btn float_r" type="button" value="reset" id="reset" name="reset" onclick="javascript:reset()"/> </form>
for reason code not working. javascript throwing following exception
typeerror: $("#frmlogin").reset not function [break on error] $("#login_form").reset()
can tell me why not working?. have included jquery.js.
according adils suggestion tried
*$("#login_form")[0].reset()*
now gives
typeerror: $("#frmlogin")[0] undefined [break on error] $("#frmlogin")[0].reset()
what missing?
i tried every code suggested bellow except amit agrawal since want use jquery. none wok. know code rest proffer. there missing in form
is there reason you've overlooked reset input element?
<input type="reset" />
Comments
Post a Comment