Differ b/w type=submit & type=button in javascript? -
Differ b/w type=submit & type=button in javascript? -
*i'm trying apply error class email label. when press button, type=submit. error class apply , page 1 time again refresh imidiately & error class doesn't apply. when same @ type=button, error class apply correctly email label..! *
<script> function check() { var email = document.getelementbyid("email"); var password = document.getelementbyid("password"); if(email.value=='') { alert("email"); email.classname = 'error'; } else { alert("not"); } } </script> <form> <table width="264" border="0"> <tr> <td width="84"><label for="email">email: </label></td> <td width="164"><input type="email" name="email" id="email" /></td> </tr> <tr> <td><label for="password">password:</label></td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><!--<input type="submit" class="signin_me" value="sign in" onclick="check();" />--> <input type="button" class="signin_me" value="sign in" onclick="check();" /> </td> </tr> </table> </form>
if utilize submit
input, click causes html form submitted. because html form not have action
attribute, submission causes same page reloaded. thus, cannot see modification have done email's classname
(because page gets reloaded after click button).
if utilize button
input, click not cause html form submitted. thus, can see modification have done email's classname
.
javascript
Comments
Post a Comment