Wiki source code of LiveValidation UI Component
Version 2.3 by Manuel Smeria on 2013/01/22
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | XWiki bundles the LiveValidation library. You can read its [[examples>>http://livevalidation.com/examples]] or the [[full documentation>>http://livevalidation.com/documentation]] on their website. | ||
2 | |||
3 | = Exemple of use in XWiki = | ||
4 | |||
5 | {{code}} | ||
6 | {{velocity output=false}} | ||
7 | $xwiki.jsfx.use('uicomponents/widgets/validation/livevalidation_prototype.js') | ||
8 | $xwiki.ssfx.use('uicomponents/widgets/validation/livevalidation.css') | ||
9 | {{/velocity}} | ||
10 | {{html}} | ||
11 | <form> | ||
12 | <div> | ||
13 | <input type="text" name="fruits" class="mandatory"> | ||
14 | </div> | ||
15 | </form> | ||
16 | <script type="text/javascript"> | ||
17 | // <![CDATA[ | ||
18 | document.observe("dom:loaded", function(){ | ||
19 | var mandatoryInputs = $('mainContentArea').select('input.mandatory'); | ||
20 | for (var i=0;i<mandatoryInputs.length;i++) { | ||
21 | var input = mandatoryInputs[i]; | ||
22 | var valid = new LiveValidation( input, { validMessage: "OK!", wait: 500 } ); | ||
23 | valid.add( Validate.Presence, | ||
24 | { failureMessage: "Mandatory" } ); | ||
25 | } | ||
26 | }); | ||
27 | // ]]> | ||
28 | }); | ||
29 | </script> | ||
30 | {{/html}} | ||
31 | {{/code}} |