javascript - jquery - validation plugin -


I am creating a simple validation plugin, if the input returns false if it is incorrect, the problem is that this plugin only One time works on an input. I want to work with all inputs at the same time.

code

  $ .fn.validate = function (options) {var defaults = {required: true, minerair: 0, MaxChar: 0}, o = $ Extension ({}, default, option); This.each (function () {var $ this = $ (this); var val = $ this.val (); if (O.quared == true & amp; val == '') {return false;} and If (ommoder & gt; 0 & amp; amp; amp; val.length & lt; o.minChar) {return false;} and if (o maxcar> gt; 0 & amp; val.length & gt; Okscar) {return false;} and {return true;}}); } ($ ('.name_inline_error').) (Validate '$' ('$ name') ()).   

call is required '); False to return; // Wrong return to stop Ajax form;} If (! $ ('$ Email'). Validate ()) {$ ('. Email_inline_error') Text ('Need Email'); False to return; // wrong return to stop the AJAX form)

What the code will do, if two inputs are empty, the plugin will only specify the name input error, only then the name input was valid, form email input However, I would like to see two errors at the same time.

When you come back, then you try to do the rest of your work like this: / P>

  valid = true; If (! $ ('. Name_in') Valid ()) {$ ('. Name_inline_error'). Text ('name is required'); Valid = false; } If valid (! $ ('# Email') ($) ($) ('. Email_inline_error') Text ('Need Email'); Valid = false; } Return valid;   

(+ 1 for Matt Ball's comment), though - rolling it on is a long time.)

Comments