EasyUI Forum
May 21, 2024, 01:32:57 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: validate form equals 2 fields  (Read 3602 times)
crosemffet
Jr. Member
**
Posts: 68



View Profile WWW Email
« on: August 28, 2018, 11:23:44 AM »

hello and thanks in advance for your support.
I've seen the extension:
// extend the 'equals' rule
$.extend($.fn.validatebox.defaults.rules, {
    equals: {
        validator: function(value,param){
            return value == $(param[0]).val();
        },
        message: 'Field do not match.'
    }
});
used to validate field a equals to field B. I need to make some change, I need to check if one specific field is equal to field B or field C, any of them return true.
example, lets pretend field fruits and need to validate with orange and apple. both orange an apple are input types hidden. any idea? regards,
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: August 28, 2018, 11:15:18 PM »

Here is the code example:
Code:
<script type="text/javascript">
$.extend($.fn.validatebox.defaults.rules, {
    equals: {
        validator: function(value,param){
        var values = $.map(param[0], function(p){
        return $(p).val();
        });
        return $.inArray(String(value), values)>=0;
        },
        message: 'Field do not match.'
    }
});
</script>
<input class="easyui-textbox" validType="equals[['#orange','#apple']]">
<input id="orange" type="hidden" value="orange">
<input id="apple" type="hidden" value="apple">
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!