EasyUI Forum
April 18, 2024, 03:03:03 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: how to set two validation in a datebox [Solve]  (Read 13094 times)
john17
Newbie
*
Posts: 17


View Profile Email
« on: July 09, 2014, 10:47:27 PM »

hi guys,


I'm working on datebox lately I'm having trouble in creating a validation if users input wrong characters and when user select greater day than today
this is my code:

Code:
<input name="date_issue" type="text" class="easyui-datebox normalsize" validType="validDate md[\'10/07/2014\']" required="true"/>
$.extend($.fn.validatebox.defaults.rules, {
            md: {
                validator: function(value, param){
                    var d1 = $.fn.datebox.defaults.parser(param[0]);
                    var d2 = $.fn.datebox.defaults.parser(value);
                    return d2<=d1;
                },
                message: 'The date must be less than or equals to {0}.'
            },
            validDate: {  
         validator: function(value){  
         var date = $.fn.datebox.defaults.parser(value);
         var s = $.fn.datebox.defaults.formatter(date);
         return s==value;
         },  
         message: 'Please enter a valid date.'  
         }
        });

thanks in advance  Grin
« Last Edit: July 10, 2014, 07:50:54 PM by john17 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 10, 2014, 02:30:39 AM »

The 'validType' property of validatebox can be an array that allows the user to apply multiple validate rules. Please try the code below:
Code:
<input name="date_issue" type="text" class="easyui-datebox normalsize" data-options="validType:['validDate','md[\'10/2/2014\']']" required="true"/>
Logged
john17
Newbie
*
Posts: 17


View Profile Email
« Reply #2 on: July 10, 2014, 07:50:19 PM »

thank you very much stworthy that did the trick  Grin Grin Grin Grin
Logged
karthi622
Newbie
*
Posts: 1


View Profile Email
« Reply #3 on: June 21, 2016, 02:28:56 AM »

How can I pass multiple values in a single array like below I have tried it but doesn't work out

Code:
<input name="date_issue" type="text" class="easyui-datebox normalsize" data-options="validType:['validDate','md[\'10/2/2014\' , \'11/2/2014\']']" required="true"/>
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!