mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
162 lines
6.0 KiB
Plaintext
162 lines
6.0 KiB
Plaintext
- consider a field-validator object that encapsulates a single element and all methods working on it
|
|
- document min/max/range methods for checkboxes/selects
|
|
|
|
/**
|
|
* Return false, if the element is
|
|
*
|
|
* - some kind of text input and its value is too short
|
|
*
|
|
* - a set of checkboxes has not enough boxes checked
|
|
*
|
|
* - a select and has not enough options selected
|
|
*
|
|
* Works with all kind of text inputs, checkboxes and select.
|
|
*
|
|
* @example <input name="firstname" class="{minLength:5}" />
|
|
* @desc Declares an optional input element with at least 5 characters (or none at all).
|
|
*
|
|
* @example <input name="firstname" class="{required:true,minLength:5}" />
|
|
* @desc Declares an input element that must have at least 5 characters.
|
|
*
|
|
* @example <fieldset>
|
|
* <legend>Spam</legend>
|
|
* <label for="spam_email">
|
|
* <input type="checkbox" id="spam_email" value="email" name="spam" validate="required:true,minLength:2" />
|
|
* Spam via E-Mail
|
|
* </label>
|
|
* <label for="spam_phone">
|
|
* <input type="checkbox" id="spam_phone" value="phone" name="spam" />
|
|
* Spam via Phone
|
|
* </label>
|
|
* <label for="spam_mail">
|
|
* <input type="checkbox" id="spam_mail" value="mail" name="spam" />
|
|
* Spam via Mail
|
|
* </label>
|
|
* <label for="spam" class="error">Please select at least two types of spam.</label>
|
|
* </fieldset>
|
|
* @desc Specifies a group of checkboxes. To validate, at least two checkboxes must be selected.
|
|
*
|
|
* @param Number min
|
|
* @name jQuery.validator.methods.minLength
|
|
* @type Boolean
|
|
* @cat Plugins/Validate/Methods
|
|
*/
|
|
|
|
/**
|
|
* Return false, if the element is
|
|
*
|
|
* - some kind of text input and its value is too short or too long
|
|
*
|
|
* - a set of checkboxes has not enough or too many boxes checked
|
|
*
|
|
* - a select and has not enough or too many options selected
|
|
*
|
|
* Works with all kind of text inputs, checkboxes and selects.
|
|
*
|
|
* @example <input name="firstname" class="{rangeLength:[3,5]}" />
|
|
* @desc Declares an optional input element with at least 3 and at most 5 characters (or none at all).
|
|
*
|
|
* @example <input name="firstname" class="{required:true,rangeLength:[3,5]}" />
|
|
* @desc Declares an input element that must have at least 3 and at most 5 characters.
|
|
*
|
|
* @example <select id="cars" class="{required:true,rangeLength:[2,3]}" multiple="multiple">
|
|
* <option value="m_sl">Mercedes SL</option>
|
|
* <option value="o_c">Opel Corsa</option>
|
|
* <option value="vw_p">VW Polo</option>
|
|
* <option value="t_s">Titanic Skoda</option>
|
|
* </select>
|
|
* @desc Specifies a select that must have at least two but no more than three options selected.
|
|
*
|
|
* @param Array<Number> min/max
|
|
* @name jQuery.validator.methods.rangeLength
|
|
* @type Boolean
|
|
* @cat Plugins/Validate/Methods
|
|
*/
|
|
|
|
- document numberOfInvalids and hideErrors
|
|
|
|
/**
|
|
* Returns the number of invalid elements in the form.
|
|
*
|
|
* @example $("#myform").validate({
|
|
* showErrors: function() {
|
|
* $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below.");
|
|
* this.defaultShowErrors();
|
|
* }
|
|
* });
|
|
* @desc Specifies a custom showErrors callback that updates the number of invalid elements each
|
|
* time the form or a single element is validated.
|
|
*
|
|
* @name jQuery.validator.prototype.numberOfInvalids
|
|
* @type Number
|
|
*/
|
|
|
|
/**
|
|
* Hides all error messages in this form.
|
|
*
|
|
* @example var validator = $("#myform").validate();
|
|
* $(".cancel").click(function() {
|
|
* validator.hideErrors();
|
|
* });
|
|
* @desc Specifies a custom showErrors callback that updates the number of invalid elements each
|
|
* time the form or a single element is validated.
|
|
*
|
|
* @name jQuery.validator.prototype.hideErrors
|
|
*/
|
|
|
|
- css references
|
|
- http://test5.caribmedia.com/CSS/Secrets/members/michiel/floating-forms.html
|
|
- http://paularmstrongdesigns.com/projects/awesomeform/
|
|
- http://dnevnikeklektika.com/uni-form/
|
|
|
|
- consider validation on page load, disabling required-checks
|
|
- completely rework showErrors: manually settings errors is currently extremely flawed and utterly useless, eg. errors disappear if some other validation is triggered
|
|
|
|
- document focusInvalid()
|
|
- document validation lifecycle: setup (add event handlers), run validation (prepare form, validate elements, display errors/submit form)
|
|
-> show where the user can hook in via callbacks
|
|
|
|
- AND dependency: specify multiple expressions as an array
|
|
|
|
- add custom events for form and elements instead of more callbacks (additional options/callbacks)
|
|
- beforeValidation: Callback, called before doing any validation
|
|
- beforeSubmit: Callback, called before submitting the form (default submit or calling submitHandler, if specified)
|
|
|
|
- animations!!
|
|
- ajax validation:
|
|
- in combination with autocomplete (mustmatch company name, fill out address details, validate required)
|
|
- validate zip code in comparison to address, if match and state is missing, fill out state
|
|
- strong password check/integration: http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
|
|
|
|
- stop firefox password manager to popup before validation - check mozilla bug tracker?
|
|
|
|
- overload addMethod with a Option-variant:
|
|
$.validator.addMethod({
|
|
name: "custom",
|
|
message: "blablabla",
|
|
parameteres: false,
|
|
handler: function() { ... }
|
|
});
|
|
|
|
Examples:
|
|
- wordpress comment form, make it a drop-in method
|
|
- ajaxForm() integration
|
|
- ajaxSubmit with rules-option, more/less options to ajaxSubmit
|
|
- watermark integration http://digitalbush.com/projects/watermark-input-plugin
|
|
- datepicker integration
|
|
- timepicker integration ( http://labs.perifer.se/timedatepicker/ )
|
|
- integration with CakePHP ( https://trac.cakephp.org/ticket/2359 )
|
|
- integration with tabs: http://www.netix.sk/forms/test.html
|
|
- integration with rich-text-editors (FCKEditor, Codepress)
|
|
http://www.fyneworks.com/jquery/FCKEditor/
|
|
|
|
2.0
|
|
---
|
|
- attachValidation, removeValidation, validate (with UI), valid (without UI)
|
|
- (re)move current addMethod implementation
|
|
- move rules plugin option
|
|
- move metadata support
|
|
- make validate method chainable
|
|
-> provide an accessor for the validator if necessary at all
|
|
- move a few default methods to additions, eg. dateXXX, creditcard, definitely accept
|