Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // reseting a form set it back to his original value.
- (function ($) {
- $.fn.reset = function () {
- $(this).each(function () {
- this.reset();
- });
- return this;
- };
- }(jQuery));
- // cleaning a form set it to an empty string or false. You can also set a default value.
- (function ($) {
- $.fn.clean = function (default_value) {
- default_value = default_value || false;
- $(this).filter('select').find('option').removeAttr('selected');
- $(this).filter(':checkbox').attr('checked', false);
- if (default_value) {
- $(this).filter(':input:not(:checkbox)').each(function () {
- $(this).val(this.defaultValue);
- });
- } else {
- $(this).filter(':input:not(:submit, :button, :reset, :checkbox, :radio)').val('');
- }
- return this;
- };
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement