Friday, August 24, 2012

Clear Form with jQuery

<html>

<head>
<script language="JavaScript" type="text/JavaScript" src="Script/jquery-1.8.0.min.js"></script>
</head>

<body>

<form id="frm">
          <input type="button"  value="Clear" onclick="resetForm('frm')" />
</form>

<script>
/**
* This function clears all input fields value except button, submit, reset, hidden fields
* */
function resetForm(formid) {
                  $(':input','#'+formid) .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked').removeAttr('selected');
 
}

</script>

</body>
</html>

No comments:

Post a Comment