Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 - consider a field-validator object that encapsulates a single element and all methods working on it
A 2 - document min/max/range methods for checkboxes/selects
3
4 /**
5  * Return false, if the element is
6  *
7  * - some kind of text input and its value is too short
8  *
9  * - a set of checkboxes has not enough boxes checked
10  *
11  * - a select and has not enough options selected
12  *
13  * Works with all kind of text inputs, checkboxes and select.
14  *
15  * @example <input name="firstname" class="{minLength:5}" />
16  * @desc Declares an optional input element with at least 5 characters (or none at all).
17  *
18  * @example <input name="firstname" class="{required:true,minLength:5}" />
19  * @desc Declares an input element that must have at least 5 characters.
20  *
21  * @example <fieldset>
22  *     <legend>Spam</legend>
23  *     <label for="spam_email">
24  *         <input type="checkbox" id="spam_email" value="email" name="spam" validate="required:true,minLength:2" />
25  *         Spam via E-Mail
26  *     </label>
27  *     <label for="spam_phone">
28  *         <input type="checkbox" id="spam_phone" value="phone" name="spam" />
29  *         Spam via Phone
30  *     </label>
31  *     <label for="spam_mail">
32  *         <input type="checkbox" id="spam_mail" value="mail" name="spam" />
33  *         Spam via Mail
34  *     </label>
35  *     <label for="spam" class="error">Please select at least two types of spam.</label>
36  * </fieldset>
37  * @desc Specifies a group of checkboxes. To validate, at least two checkboxes must be selected.
38  *
39  * @param Number min
40  * @name jQuery.validator.methods.minLength
41  * @type Boolean
42  * @cat Plugins/Validate/Methods
43  */
44  
45  /**
46  * Return false, if the element is
47  *
48  * - some kind of text input and its value is too short or too long
49  *
50  * - a set of checkboxes has not enough or too many boxes checked
51  *
52  * - a select and has not enough or too many options selected
53  *
54  * Works with all kind of text inputs, checkboxes and selects.
55  *
56  * @example <input name="firstname" class="{rangeLength:[3,5]}" />
57  * @desc Declares an optional input element with at least 3 and at most 5 characters (or none at all).
58  *
59  * @example <input name="firstname" class="{required:true,rangeLength:[3,5]}" />
60  * @desc Declares an input element that must have at least 3 and at most 5 characters.
61  *
62  * @example <select id="cars" class="{required:true,rangeLength:[2,3]}" multiple="multiple">
63  *     <option value="m_sl">Mercedes SL</option>
64  *     <option value="o_c">Opel Corsa</option>
65  *     <option value="vw_p">VW Polo</option>
66  *     <option value="t_s">Titanic Skoda</option>
67  * </select>
68  * @desc Specifies a select that must have at least two but no more than three options selected.
69  *
70  * @param Array<Number> min/max
71  * @name jQuery.validator.methods.rangeLength
72  * @type Boolean
73  * @cat Plugins/Validate/Methods
74  */
75  
76 - document numberOfInvalids and hideErrors
77
78 /**
79  * Returns the number of invalid elements in the form.
80  * 
81  * @example $("#myform").validate({
82  *     showErrors: function() {
83  *         $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below.");
84  *         this.defaultShowErrors();
85  *     }
86  * });
87  * @desc Specifies a custom showErrors callback that updates the number of invalid elements each
88  * time the form or a single element is validated.
89  * 
90  * @name jQuery.validator.prototype.numberOfInvalids
91  * @type Number
92  */
93  
94  /**
95  * Hides all error messages in this form.
96  * 
97  * @example var validator = $("#myform").validate();
98  * $(".cancel").click(function() {
99  *     validator.hideErrors();
100  * });
101  * @desc Specifies a custom showErrors callback that updates the number of invalid elements each
102  * time the form or a single element is validated.
103  * 
104  * @name jQuery.validator.prototype.hideErrors
105  */
106
107 - css references
108  - http://test5.caribmedia.com/CSS/Secrets/members/michiel/floating-forms.html
109  - http://paularmstrongdesigns.com/projects/awesomeform/
110  - http://dnevnikeklektika.com/uni-form/
111
112 - consider validation on page load, disabling required-checks
113 - completely rework showErrors: manually settings errors is currently extremely flawed and utterly useless, eg. errors disappear if some other validation is triggered
114
115 - document focusInvalid()
116 - document validation lifecycle: setup (add event handlers), run validation (prepare form, validate elements, display errors/submit form)
117      -> show where the user can hook in via callbacks
118      
119 - AND dependency: specify multiple expressions as an array
120
121 - add custom events for form and elements instead of more callbacks (additional options/callbacks)
122  - beforeValidation: Callback, called before doing any validation
123  - beforeSubmit: Callback, called before submitting the form (default submit or calling submitHandler, if specified) 
124
125 - animations!!
126 - ajax validation:
127     - in combination with autocomplete (mustmatch company name, fill out address details, validate required)
128     - validate zip code in comparison to address, if match and state is missing, fill out state
129 - strong password check/integration: http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
130
131 - stop firefox password manager to popup before validation - check mozilla bug tracker?
132
133 - overload addMethod with a Option-variant:
134 $.validator.addMethod({
135   name: "custom",
136   message: "blablabla",
137   parameteres: false,
138   handler: function() { ... }
139 });
140
141  Examples:
142  - wordpress comment form, make it a drop-in method
143  - ajaxForm() integration
144  - ajaxSubmit with rules-option, more/less options to ajaxSubmit
145  - watermark integration http://digitalbush.com/projects/watermark-input-plugin
146  - datepicker integration
147  - timepicker integration ( http://labs.perifer.se/timedatepicker/ ) 
148  - integration with CakePHP ( https://trac.cakephp.org/ticket/2359 )
149  - integration with tabs: http://www.netix.sk/forms/test.html 
150  - integration with rich-text-editors (FCKEditor, Codepress)
151     http://www.fyneworks.com/jquery/FCKEditor/
152
153 2.0
154 ---
155 - attachValidation, removeValidation, validate (with UI), valid (without UI)
156 - (re)move current addMethod implementation
157 - move rules plugin option
158 - move metadata support
159 - make validate method chainable
160   -> provide an accessor for the validator if necessary at all 
161 - move a few default methods to additions, eg. dateXXX, creditcard, definitely accept