Plugin Directory

Changeset 3451239


Ignore:
Timestamp:
02/01/2026 06:09:56 AM (8 weeks ago)
Author:
pluginscafe
Message:

alpha limit checkbox addon support

Location:
gf-real-time-validation
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • gf-real-time-validation/trunk/class-gfrtv.php

    r3200160 r3451239  
    11<?php
    2 
     2if (! defined('ABSPATH')) exit;
    33GFForms::include_addon_framework();
    44
     
    88    protected $_min_gravityforms_version = '1.9';
    99    protected $_slug = 'real-time-validation';
    10     protected $_path = 'rtv-gravityforms/real-time-validation.php';
     10    protected $_path = 'gf-real-time-validation/real-time-validation.php';
    1111    protected $_full_path = __FILE__;
    1212    protected $_title = 'Real Time Validation For Gravity Forms';
     
    5151                <input type="checkbox" id="enable_gfrtv" onclick="SetFieldProperty('enableGFRTV', this.checked);" />
    5252                <label for="enable_gfrtv" style="display:inline;">
    53                     <?php _e("Enable Real Time Validation", "gfrtv"); ?>
     53                    <?php esc_html_e("Enable Real Time Validation", "gfrtv"); ?>
    5454                    <?php gform_tooltip("gfrtv_enable_regex"); ?>
    5555                </label>
     
    6161            <li class="regexp_validation_message field_setting">
    6262                <label for="regexp_validation_message" class="section_label">
    63                     <?php _e("Validation failed message", "gravityforms"); ?>
     63                    <?php esc_html_e("Validation failed message", "gfrtv"); ?>
    6464                    <?php gform_tooltip("gfrtv_error_message"); ?>
    6565                </label>
     
    141141        if ($field->type == 'multi_choice' || $field->type == 'image_choice') {
    142142            if ($field->choiceLimit == 'exactly') {
    143                 return $field->errorMessage ? $field->errorMessage : esc_html__('Select exactly ' . $field->choiceLimitNumber . ' choices.', 'gfrtv');
     143                return $field->errorMessage ? $field->errorMessage : esc_html(
     144                    sprintf(
     145                        /* translators: 1: minimum choices */
     146                        esc_html__('Select exactly %d choices.', 'gfrtv'),
     147                        $field->choiceLimitNumber
     148                    )
     149                );
    144150            }
    145151
    146152            if ($field->choiceLimit == 'range') {
    147                 return $field->errorMessage ? $field->errorMessage : esc_html__('Select between ' . $field->choiceLimitMin . ' and ' . $field->choiceLimitMax . ' choices.', 'gfrtv');
     153                return $field->errorMessage ? $field->errorMessage :
     154                    sprintf(
     155                        /* translators: 1: minimum choices, 2: maximum choices */
     156                        esc_html__('Select between %1$d and %2$d choices.', 'gfrtv'),
     157                        $field->choiceLimitMin,
     158                        $field->choiceLimitMax
     159                    );
    148160            }
    149161
     
    201213            }
    202214        }
     215
     216        if (class_exists('ALPHAGF_Limit_Checkbox')) {
     217            if ($field->type == 'checkbox' && !empty($field->alphagf_limit_number)) {
     218                $field_data['limit'] = $field->alphagf_limit_number;
     219                $field_data['limit_type'] = 'exactly';
     220            }
     221        }
     222
    203223
    204224        return (object) $field_data;
     
    228248            if (in_array($field->type, $this->_supported_field_types) && ($field->isRequired || ($field->enableGFRTV && $field->regexpValue))) {
    229249                $fields_data[] = json_encode($this->genarate_js_data($field));
     250            } else if ($field->type == 'checkbox' && $field->alphagf_limit_number) {
     251                $fields_data[] = json_encode($this->genarate_js_data($field));
    230252            }
    231253        }
     
    235257        }
    236258
    237         wp_enqueue_script('gfrtv_script', $this->get_base_url() . '/js/gfrtv_script.js', array('jquery'), $this->_version);
     259        wp_enqueue_script('gfrtv_script', $this->get_base_url() . '/js/gfrtv_script.js', array('jquery'), $this->_version, true);
    238260        wp_localize_script(
    239261            'gfrtv_script',
  • gf-real-time-validation/trunk/js/gfrtv_script.js

    r3200160 r3451239  
    2323                multiChoiceType = FD["limit_type"] ? FD["limit_type"] : null,
    2424                limitItems = {
    25                     'limitExactly' : FD["limit"] ? FD["limit"] : null,
    26                     'limitMin' : FD["min"] ? FD["min"] : null,
    27                     'limitMax' : FD["max"] ? FD["max"] : null,
     25                    'limitExactly': FD["limit"] ? FD["limit"] : null,
     26                    'limitMin': FD["min"] ? FD["min"] : null,
     27                    'limitMax': FD["max"] ? FD["max"] : null,
     28                },
     29                limitCheckbox = {
     30                    'limit': FD["limit"] ? FD["limit"] : null,
     31                    'type': FD['limit_type'] ? FD['limit_type'] : null
    2832                },
    2933                regEx = {
    30                     'pattern' : FD['regex'],
    31                     'enableRegex' : FD['enableRegex'],
    32                     'errorMessage' : FD['regErrorMessage']
     34                    'pattern': FD['regex'],
     35                    'enableRegex': FD['enableRegex'],
     36                    'errorMessage': FD['regErrorMessage']
    3337                };
    3438
    3539            GF_RTV.standardField(inputId, fieldType, errorMessage, regEx);
    36             GF_RTV.choicesType(inputId, fieldType, errorMessage);
     40            GF_RTV.choicesType(inputId, fieldType, errorMessage, limitCheckbox);
    3741            GF_RTV.numberField(inputId, fieldType);
    3842            GF_RTV.urlType(inputId, fieldType, errorMessage, notMatch);
     
    5559            GF_RTV.multipleChoices(inputId, fieldType, multiChoiceType, limitItems, errorMessage);
    5660        },
    57         multipleChoices: function( inputId, fieldType, multiChoiceType, limitItems, errorMessage ) {
     61        multipleChoices: function (inputId, fieldType, multiChoiceType, limitItems, errorMessage) {
    5862            if (!GF_RTV.gformInputType["multiChoice"].includes(fieldType)) return;
    5963
     
    7074                    GF_RTV.rangeChoices(inputId, fieldType, limitItems, errorMessage);
    7175                    break;
    72            
     76
    7377                default:
    7478                    GF_RTV.radioType(inputId, errorMessage);
     
    7680            }
    7781        },
    78         rangeChoices: function( inputId, fieldType, limitItems, errorMessage ){
    79             if( fieldType == 'image_choice' ) {
    80                 GF_RTV.imageChoiceOps( inputId, limitItems.limitMax, errorMessage );
     82        rangeChoices: function (inputId, fieldType, limitItems, errorMessage) {
     83            if (fieldType == 'image_choice') {
     84                GF_RTV.imageChoiceOps(inputId, limitItems.limitMax, errorMessage);
    8185            } else {
    8286                jQuery(inputId).on("change", function () {
    8387                    var checkCount = jQuery(inputId + " input[type=checkbox]:checked").length;
    84                     if( checkCount <= parseInt(limitItems.limitMax) ) {
     88                    if (checkCount <= parseInt(limitItems.limitMax)) {
    8589                        GF_RTV.validationSuccess(jQuery(this));
    8690                    } else {
     
    9094            }
    9195        },
    92         exactlyChoices: function(inputId, fieldType, limitItems, errorMessage) {
    93             if( fieldType == 'image_choice' ) {
    94                 GF_RTV.imageChoiceOps( inputId, limitItems.limitExactly, errorMessage );
     96        exactlyChoices: function (inputId, fieldType, limitItems, errorMessage) {
     97            if (fieldType == 'image_choice') {
     98                GF_RTV.imageChoiceOps(inputId, limitItems.limitExactly, errorMessage);
    9599            } else {
    96100                jQuery(inputId).on("change", function () {
    97101                    var checkCount = jQuery(inputId + " input[type=checkbox]:checked").length;
    98                    
    99                     if( checkCount <= parseInt(limitItems.limitExactly) ) {
     102
     103                    if (checkCount <= parseInt(limitItems.limitExactly)) {
    100104                        GF_RTV.validationSuccess(jQuery(this));
    101105                    } else {
     
    105109            }
    106110        },
    107         imageChoiceOps: function( inputId, limitItems, errorMessage, type = '' ) {
    108             jQuery(inputId + ' .gchoice').on("click", function ( e ) {
     111        imageChoiceOps: function (inputId, limitItems, errorMessage, type = '') {
     112            jQuery(inputId + ' .gchoice').on("click", function (e) {
    109113                e.stopPropagation();
    110114                e.preventDefault();
    111115
    112116                var checkbox = jQuery(this).find('input[type="checkbox"]');
    113                     checkbox.prop('checked', !checkbox.prop('checked'));
    114            
    115                 var parentContainer = jQuery(this).closest('.gfield_checkbox');   
     117                checkbox.prop('checked', !checkbox.prop('checked'));
     118
     119                var parentContainer = jQuery(this).closest('.gfield_checkbox');
    116120                var checkCount = parentContainer.find('input[type="checkbox"]:checked').length;
    117121
    118                 if( type == 'unlimited' ) {
    119                     if( checkCount) {
    120                         GF_RTV.validationSuccess(jQuery(this));
    121                     } else {
    122                         GF_RTV.validationFail(jQuery(this), errorMessage);
    123                     }
    124                 } else {
    125                     if( checkCount <= parseInt(limitItems) ) {
     122                if (type == 'unlimited') {
     123                    if (checkCount) {
     124                        GF_RTV.validationSuccess(jQuery(this));
     125                    } else {
     126                        GF_RTV.validationFail(jQuery(this), errorMessage);
     127                    }
     128                } else {
     129                    if (checkCount <= parseInt(limitItems)) {
    126130                        GF_RTV.validationSuccess(jQuery(this));
    127131                    } else {
     
    137141                var thisValue = jQuery(this).val();
    138142
    139                 if( regEx.enableRegex && errorMessage !== undefined) {
    140                     if( thisValue != '' ) {
    141                         GF_RTV.validationSuccess(jQuery(this));
    142                         if( GF_RTV.regexValidationFail( regEx, thisValue ) ) {
     143                if (regEx.enableRegex && errorMessage !== undefined) {
     144                    if (thisValue != '') {
     145                        GF_RTV.validationSuccess(jQuery(this));
     146                        if (GF_RTV.regexValidationFail(regEx, thisValue)) {
    143147                            GF_RTV.validationSuccess(jQuery(this));
    144148                        } else {
     
    148152                        GF_RTV.validationFail(jQuery(this), errorMessage);
    149153                    }
    150                 } else if( regEx.enableRegex && errorMessage === undefined) {
    151                     if( GF_RTV.regexValidationFail( regEx, thisValue ) && thisValue != '') {
    152                         GF_RTV.validationSuccess(jQuery(this));
    153                     } else if( thisValue == '' ){
     154                } else if (regEx.enableRegex && errorMessage === undefined) {
     155                    if (GF_RTV.regexValidationFail(regEx, thisValue) && thisValue != '') {
     156                        GF_RTV.validationSuccess(jQuery(this));
     157                    } else if (thisValue == '') {
    154158                        GF_RTV.validationSuccess(jQuery(this));
    155159                    } else {
     
    157161                    }
    158162                } else {
    159                     if( thisValue != '') {
    160                         GF_RTV.validationSuccess(jQuery(this));
    161                     } else {
    162                         GF_RTV.validationFail(jQuery(this), errorMessage);
    163                     }
    164                 }
    165             });
    166         },
    167         regexValidationFail: function( regex, value ) {
    168             if( regex.pattern === undefined || regex.pattern === '' ) {
     163                    if (thisValue != '') {
     164                        GF_RTV.validationSuccess(jQuery(this));
     165                    } else {
     166                        GF_RTV.validationFail(jQuery(this), errorMessage);
     167                    }
     168                }
     169            });
     170        },
     171        regexValidationFail: function (regex, value) {
     172            if (regex.pattern === undefined || regex.pattern === '') {
    169173                return false;
    170174            }
    171            
    172             let regCode =  new RegExp(regex.pattern);
    173             return regCode.test( value );
     175
     176            let regCode = new RegExp(regex.pattern);
     177            return regCode.test(value);
    174178        },
    175179        numberField: function (inputId, fieldType) {
     
    372376            });
    373377        },
    374         choicesType: function (inputId, fieldType, errorMessage) {
     378        choicesType: function (inputId, fieldType, errorMessage, limitItems = '') {
    375379            if (!GF_RTV.gformInputType["choices"].includes(fieldType)) return;
    376380
     
    381385
    382386                case "checkbox":
    383                     GF_RTV.checkboxType(inputId, errorMessage);
     387                    GF_RTV.checkboxType(inputId, errorMessage, limitItems);
    384388                    break;
    385389
     
    407411        },
    408412        checkboxType: function (inputId, errorMessage, fieldType = '') {
    409             if( fieldType == 'image_choice' ) {
    410                 GF_RTV.imageChoiceOps( inputId, '1', errorMessage, 'unlimited');
     413            if (fieldType == 'image_choice') {
     414                GF_RTV.imageChoiceOps(inputId, '1', errorMessage, 'unlimited');
    411415            } else {
    412416                jQuery(inputId).on("change", function () {
    413                     if (jQuery(inputId + " input[type=checkbox]:checked").length) {
    414                         GF_RTV.validationSuccess(jQuery(this));
     417                    var checkboxLength = jQuery(inputId + " input[type=checkbox]:checked").length;
     418                    if (checkboxLength) {
     419                        if (fieldType.limit != null) {
     420                            var errorText = 'Please select exactly ' + fieldType.limit + ' checkbox.';
     421                            if (checkboxLength <= fieldType.limit) {
     422                                GF_RTV.validationSuccess(jQuery(this));
     423                            } else {
     424                                GF_RTV.validationFail(jQuery(this), errorText);
     425                            }
     426                        } else {
     427                            GF_RTV.validationSuccess(jQuery(this));
     428                        }
    415429                    } else {
    416430                        GF_RTV.validationFail(jQuery(this), errorMessage);
     
    472486                .append(
    473487                    '<div class="gfield_description validation_message gfield_validation_message">' +
    474                         errorMessage +
    475                         " " +
    476                         validInputs.join(", ") +
    477                         ".</div>"
     488                    errorMessage +
     489                    " " +
     490                    validInputs.join(", ") +
     491                    ".</div>"
    478492                );
    479493        },
     
    493507                    .append(
    494508                        '<div class="gfield_description validation_message gfield_validation_message">' +
    495                             errorMessage +
    496                             ".</div>"
     509                        errorMessage +
     510                        ".</div>"
    497511                    );
    498512            } else {
     
    508522                    .append(
    509523                        '<div class="gfield_description validation_message gfield_validation_message">' +
    510                             errorMessage +
    511                             ".</div>"
     524                        errorMessage +
     525                        ".</div>"
    512526                    );
    513527            }
     
    556570                .append(
    557571                    '<div class="gfield_description validation_message gfield_validation_message">' +
    558                         errorMessage +
    559                         "</div>"
     572                    errorMessage +
     573                    "</div>"
    560574                );
    561575        }
    562        
    563576    };
    564577
  • gf-real-time-validation/trunk/readme.txt

    r3200169 r3451239  
    55Requires at least: 5.6
    66Requires PHP: 7.4
    7 Tested up to: 6.7.1
    8 Stable tag: 1.0.3
     7Tested up to: 6.9
     8Stable tag: 1.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
     
    5959^(\+?\d{1,4}[\s-]?)?(\(?\d{3,4}\)?[\s-]?)?\d{3}[\s-]?\d{3,4}$
    6060
     61<strong>Our Others Plugins</strong>
     62[Alpha Addons for Gravity Forms](https://wordpress.org/plugins/alpha-addons-for-gravity-forms/)
     63[Smart Phone Field for Gravity Forms](https://wordpress.org/plugins/smart-phone-field-for-gravity-forms/)
     64[Smart Phone Field for Fluent Forms](https://wordpress.org/plugins/smart-phone-field-for-wp-forms/)
     65[Smart Phone Field for Contact Form 7](https://wordpress.org/plugins/smart-phone-field-for-wp-forms/)
     66[Smart Phone Field for Elementor Form](https://wordpress.org/plugins/smart-phone-field-for-wp-forms/)
     67[Image Picker for Gravity Forms](https://wordpress.org/plugins/image-choices-for-gravity-forms/)
     68[Range Slider for Gravity Forms](https://wordpress.org/plugins/range-slider-addon-for-gravity-forms/)
     69[Address AutoComplete for Gravity Forms](https://wordpress.org/plugins/gf-google-address-autocomplete/)
     70[Restrict Dates for Gravity Forms](https://wordpress.org/plugins/restrict-dates-add-on-for-gravity-forms/)
    6171
    6272= Requirements =
     
    7383
    7484== Change log ==
     85
     86= 1.0.4 =
     87* Added 'Alpha Addons For Gravity Forms' Limit checkbox addon support
     88* Other bug fix
    7589
    7690= 1.0.3 =
  • gf-real-time-validation/trunk/real-time-validation.php

    r3200160 r3451239  
    11<?php
    22/*
    3 * Plugin Name: Real Time Validation for Gravity Forms
     3* Plugin Name: Real Time Validation For Gravity Forms
    44* Plugin Url: https://pluginscafe.com/plugin/real-time-validation-for-gravity-forms
    5 * Version: 1.0.3
     5* Version: 1.0.4
    66* Description: This plugin adds an awesome feature that provides instant feedback and guidance in each field, helps prevent errors.
    7 * Author: Pluginscafe
     7* Author: PluginsCafe
    88* Author URI: https://pluginscafe.com
    99* License: GPLv2 or later
     
    1616}
    1717
    18 define('REAL_TIME_VALIDATION_ADDON_VERSION', '1.0.3');
     18define('REAL_TIME_VALIDATION_ADDON_VERSION', '1.0.4');
    1919
    2020add_action('gform_loaded', array('GF_Real_Time_Validation_AddOn_Bootstrap', 'load'), 5);
     
    3939    return GFRTVAddOn::get_instance();
    4040}
    41 
    42 // Translate direction
    43 function gfrtv_localization_setup() {
    44     load_plugin_textdomain('gfrtv', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    45 }
    46 add_action('init', 'gfrtv_localization_setup');
Note: See TracChangeset for help on using the changeset viewer.