EasyUI Forum

General Category => General Discussion => Topic started by: john17 on July 09, 2014, 10:47:27 PM



Title: how to set two validation in a datebox [Solve]
Post by: john17 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  ;D


Title: Re: how to set two validation in a datebox
Post by: stworthy 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"/>


Title: Re: how to set two validation in a datebox
Post by: john17 on July 10, 2014, 07:50:19 PM
thank you very much stworthy that did the trick  ;D ;D ;D ;D


Title: Re: how to set two validation in a datebox [Solve]
Post by: karthi622 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"/>