Live Validation

Last modified by Anca Luca on 2023/10/20

XWiki bundles the LiveValidation library. You can read its examples or the full documentation on their website. You may also be interested by the LiveValidation Macros extensions.

Example of use in XWiki

{{velocity output=false}}
$xwiki.jsfx.use('uicomponents/widgets/validation/livevalidation_prototype.js')
$xwiki.ssfx.use('uicomponents/widgets/validation/livevalidation.css')
{{/velocity}}

{{html}}
<form method="get" action="">
 <p><input type="text" name="fruits" class="mandatory"/></p>
 <p><button>Submit</button></p>
</form>
<script>
 require(['jquery'], function ($) {
    $(function () {
     var mandatoryInputs = $('input.mandatory');
     mandatoryInputs.each(function(i){
       var valid = new LiveValidation( this, { validMessage: "OK!", wait: 500 } );
       valid.add( Validate.Presence, { failureMessage: "Mandatory" } );        
      })
    });
  });
</script>
{{/html}}
Tags:
   

Get Connected