Wiki source code of Live Validation

Last modified by Anca Luca on 2023/10/20

Show last authors
1 XWiki bundles the LiveValidation library. You can read its [[examples>>https://web.archive.org/web/20150317065621/http://livevalidation.com/examples]] or the [[full documentation>>https://web.archive.org/web/20150315055649/http://livevalidation.com/documentation]] on their website. You may also be interested by the [[LiveValidation Macros>>extensions:Extension.LiveValidation Macros]] extensions.
2
3 = Example 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
11 {{html}}
12 <form method="get" action="">
13 <p><input type="text" name="fruits" class="mandatory"/></p>
14 <p><button>Submit</button></p>
15 </form>
16 <script>
17 require(['jquery'], function ($) {
18 $(function () {
19 var mandatoryInputs = $('input.mandatory');
20 mandatoryInputs.each(function(i){
21 var valid = new LiveValidation( this, { validMessage: "OK!", wait: 500 } );
22 valid.add( Validate.Presence, { failureMessage: "Mandatory" } );
23 })
24 });
25 });
26 </script>
27 {{/html}}
28 {{/code}}

Get Connected