EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: andyj on June 16, 2014, 12:26:31 PM



Title: delay field validation when required:true
Post by: andyj on June 16, 2014, 12:26:31 PM
I would like to delay field validation warnings and behaviour from firing upon loading a form.
Using the "delay:bignumber" data option works fine for the built-in field validation rules like email, url but it doesn't work for "required:true"

Is there any way of making a field required but delaying validation messages until either the form is submitted or a user has tabbed off the field (onblur)?

Thanks.


Title: Re: delay field validation when required:true
Post by: stworthy on June 16, 2014, 05:01:55 PM
You may need to call 'disableValidation' method to disable the form validation first. Before submit a form, call 'enableValidation' method to enable validation again. Please try the code below:
Code:
$('#ff').form('submit',{
onSubmit:function(){
$(this).form('enableValidation');
return $(this).form('validate');
}
})


Title: Re: delay field validation when required:true
Post by: andyj on June 18, 2014, 04:33:49 AM
Thank you!
Works like a charm.

For anyone interested in how to delay field validation messages from being displayed until a form is submitted this is how:

Code:
<script type="text/javascript">
$(document).ready(function(){
//Disable validation upon loading the document
$('#fm').form('disableValidation');
})

function submitform(){
//Re-enable validation upon loading the document
$('#fm').form('enableValidation');
//Submit form function as normal
$('#fm').form('submit',{
 url: 'data_changepassword.php',
 onSubmit: function(){
 ... etc.