EasyUI Forum
May 03, 2024, 07:52:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: delay field validation when required:true  (Read 5899 times)
andyj
Jr. Member
**
Posts: 57



View Profile
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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');
}
})
Logged
andyj
Jr. Member
**
Posts: 57



View Profile
« Reply #2 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!