Wiki source code of Live Validation

Last modified by Anca Luca on 2023/10/20

Hide last authors
Anca Luca 8.1 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.
Jerome 1.1 2
Hassan Ali 4.4 3 = Example of use in XWiki =
Jerome 1.1 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}}
Raphaël Jakse 6.2 10
Jerome 1.1 11 {{html}}
Raphaël Jakse 6.2 12 <form method="get" action="">
13 <p><input type="text" name="fruits" class="mandatory"/></p>
14 <p><button>Submit</button></p>
Jerome 1.1 15 </form>
Raphaël Jakse 6.2 16 <script>
17 require(['jquery'], function ($) {
18 $(function () {
19 var mandatoryInputs = $('input.mandatory');
Anca Luca 9.1 20 mandatoryInputs.each(function(i){
21 var valid = new LiveValidation( this, { validMessage: "OK!", wait: 500 } );
22 valid.add( Validate.Presence, { failureMessage: "Mandatory" } );
23 })
Raphaël Jakse 6.2 24 });
25 });
Jerome 1.1 26 </script>
27 {{/html}}
28 {{/code}}

Get Connected