-
-
Save Zlabst/0b50d524a791b89c9575db623e444826 to your computer and use it in GitHub Desktop.
Easy Form Validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Easy Form Validator | |
| //Example: $("form").evalid("Error message"); | |
| //Author URL: http://webdesign-master.ru | |
| (function($) { | |
| $.fn.evalid = function(req_text) { | |
| $(this).find("input[type], textarea").each(function() { | |
| $(this).after("<p class='form_error_message'>" + req_text + "").next().hide(); | |
| }); | |
| $(this).submit(function(event) { | |
| $(this).find("input[type], textarea").each(function() { | |
| var attr = $(this).attr("data"); | |
| if (typeof attr !== typeof undefined && attr !== false) { | |
| if($(this).val() == "") { | |
| $(this).addClass("input_error"); | |
| $(this).next().show(); | |
| event.preventDefault(); | |
| } else { | |
| $(this).removeClass("input_error"); | |
| $(this).next().hide(); | |
| }; | |
| }; | |
| }); | |
| }); | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment