Changeset 3451239
- Timestamp:
- 02/01/2026 06:09:56 AM (8 weeks ago)
- Location:
- gf-real-time-validation
- Files:
-
- 8 added
- 4 edited
-
tags/1.0.4 (added)
-
tags/1.0.4/class-gfrtv.php (added)
-
tags/1.0.4/js (added)
-
tags/1.0.4/js/gfrtv_script.js (added)
-
tags/1.0.4/languages (added)
-
tags/1.0.4/readme.txt (added)
-
tags/1.0.4/real-time-validation.php (added)
-
trunk/class-gfrtv.php (modified) (8 diffs)
-
trunk/js/gfrtv_script.js (modified) (16 diffs)
-
trunk/languages (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/real-time-validation.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gf-real-time-validation/trunk/class-gfrtv.php
r3200160 r3451239 1 1 <?php 2 2 if (! defined('ABSPATH')) exit; 3 3 GFForms::include_addon_framework(); 4 4 … … 8 8 protected $_min_gravityforms_version = '1.9'; 9 9 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'; 11 11 protected $_full_path = __FILE__; 12 12 protected $_title = 'Real Time Validation For Gravity Forms'; … … 51 51 <input type="checkbox" id="enable_gfrtv" onclick="SetFieldProperty('enableGFRTV', this.checked);" /> 52 52 <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"); ?> 54 54 <?php gform_tooltip("gfrtv_enable_regex"); ?> 55 55 </label> … … 61 61 <li class="regexp_validation_message field_setting"> 62 62 <label for="regexp_validation_message" class="section_label"> 63 <?php _e("Validation failed message", "gravityforms"); ?>63 <?php esc_html_e("Validation failed message", "gfrtv"); ?> 64 64 <?php gform_tooltip("gfrtv_error_message"); ?> 65 65 </label> … … 141 141 if ($field->type == 'multi_choice' || $field->type == 'image_choice') { 142 142 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 ); 144 150 } 145 151 146 152 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 ); 148 160 } 149 161 … … 201 213 } 202 214 } 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 203 223 204 224 return (object) $field_data; … … 228 248 if (in_array($field->type, $this->_supported_field_types) && ($field->isRequired || ($field->enableGFRTV && $field->regexpValue))) { 229 249 $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)); 230 252 } 231 253 } … … 235 257 } 236 258 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); 238 260 wp_localize_script( 239 261 'gfrtv_script', -
gf-real-time-validation/trunk/js/gfrtv_script.js
r3200160 r3451239 23 23 multiChoiceType = FD["limit_type"] ? FD["limit_type"] : null, 24 24 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 28 32 }, 29 33 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'] 33 37 }; 34 38 35 39 GF_RTV.standardField(inputId, fieldType, errorMessage, regEx); 36 GF_RTV.choicesType(inputId, fieldType, errorMessage );40 GF_RTV.choicesType(inputId, fieldType, errorMessage, limitCheckbox); 37 41 GF_RTV.numberField(inputId, fieldType); 38 42 GF_RTV.urlType(inputId, fieldType, errorMessage, notMatch); … … 55 59 GF_RTV.multipleChoices(inputId, fieldType, multiChoiceType, limitItems, errorMessage); 56 60 }, 57 multipleChoices: function ( inputId, fieldType, multiChoiceType, limitItems, errorMessage) {61 multipleChoices: function (inputId, fieldType, multiChoiceType, limitItems, errorMessage) { 58 62 if (!GF_RTV.gformInputType["multiChoice"].includes(fieldType)) return; 59 63 … … 70 74 GF_RTV.rangeChoices(inputId, fieldType, limitItems, errorMessage); 71 75 break; 72 76 73 77 default: 74 78 GF_RTV.radioType(inputId, errorMessage); … … 76 80 } 77 81 }, 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); 81 85 } else { 82 86 jQuery(inputId).on("change", function () { 83 87 var checkCount = jQuery(inputId + " input[type=checkbox]:checked").length; 84 if ( checkCount <= parseInt(limitItems.limitMax)) {88 if (checkCount <= parseInt(limitItems.limitMax)) { 85 89 GF_RTV.validationSuccess(jQuery(this)); 86 90 } else { … … 90 94 } 91 95 }, 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); 95 99 } else { 96 100 jQuery(inputId).on("change", function () { 97 101 var checkCount = jQuery(inputId + " input[type=checkbox]:checked").length; 98 99 if ( checkCount <= parseInt(limitItems.limitExactly)) {102 103 if (checkCount <= parseInt(limitItems.limitExactly)) { 100 104 GF_RTV.validationSuccess(jQuery(this)); 101 105 } else { … … 105 109 } 106 110 }, 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) { 109 113 e.stopPropagation(); 110 114 e.preventDefault(); 111 115 112 116 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'); 116 120 var checkCount = parentContainer.find('input[type="checkbox"]:checked').length; 117 121 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)) { 126 130 GF_RTV.validationSuccess(jQuery(this)); 127 131 } else { … … 137 141 var thisValue = jQuery(this).val(); 138 142 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)) { 143 147 GF_RTV.validationSuccess(jQuery(this)); 144 148 } else { … … 148 152 GF_RTV.validationFail(jQuery(this), errorMessage); 149 153 } 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 == '') { 154 158 GF_RTV.validationSuccess(jQuery(this)); 155 159 } else { … … 157 161 } 158 162 } 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 === '') { 169 173 return false; 170 174 } 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); 174 178 }, 175 179 numberField: function (inputId, fieldType) { … … 372 376 }); 373 377 }, 374 choicesType: function (inputId, fieldType, errorMessage ) {378 choicesType: function (inputId, fieldType, errorMessage, limitItems = '') { 375 379 if (!GF_RTV.gformInputType["choices"].includes(fieldType)) return; 376 380 … … 381 385 382 386 case "checkbox": 383 GF_RTV.checkboxType(inputId, errorMessage );387 GF_RTV.checkboxType(inputId, errorMessage, limitItems); 384 388 break; 385 389 … … 407 411 }, 408 412 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'); 411 415 } else { 412 416 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 } 415 429 } else { 416 430 GF_RTV.validationFail(jQuery(this), errorMessage); … … 472 486 .append( 473 487 '<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>" 478 492 ); 479 493 }, … … 493 507 .append( 494 508 '<div class="gfield_description validation_message gfield_validation_message">' + 495 errorMessage +496 ".</div>"509 errorMessage + 510 ".</div>" 497 511 ); 498 512 } else { … … 508 522 .append( 509 523 '<div class="gfield_description validation_message gfield_validation_message">' + 510 errorMessage +511 ".</div>"524 errorMessage + 525 ".</div>" 512 526 ); 513 527 } … … 556 570 .append( 557 571 '<div class="gfield_description validation_message gfield_validation_message">' + 558 errorMessage +559 "</div>"572 errorMessage + 573 "</div>" 560 574 ); 561 575 } 562 563 576 }; 564 577 -
gf-real-time-validation/trunk/readme.txt
r3200169 r3451239 5 5 Requires at least: 5.6 6 6 Requires PHP: 7.4 7 Tested up to: 6. 7.18 Stable tag: 1.0. 37 Tested up to: 6.9 8 Stable tag: 1.0.4 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html … … 59 59 ^(\+?\d{1,4}[\s-]?)?(\(?\d{3,4}\)?[\s-]?)?\d{3}[\s-]?\d{3,4}$ 60 60 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/) 61 71 62 72 = Requirements = … … 73 83 74 84 == Change log == 85 86 = 1.0.4 = 87 * Added 'Alpha Addons For Gravity Forms' Limit checkbox addon support 88 * Other bug fix 75 89 76 90 = 1.0.3 = -
gf-real-time-validation/trunk/real-time-validation.php
r3200160 r3451239 1 1 <?php 2 2 /* 3 * Plugin Name: Real Time Validation for Gravity Forms3 * Plugin Name: Real Time Validation For Gravity Forms 4 4 * Plugin Url: https://pluginscafe.com/plugin/real-time-validation-for-gravity-forms 5 * Version: 1.0. 35 * Version: 1.0.4 6 6 * Description: This plugin adds an awesome feature that provides instant feedback and guidance in each field, helps prevent errors. 7 * Author: Plugins cafe7 * Author: PluginsCafe 8 8 * Author URI: https://pluginscafe.com 9 9 * License: GPLv2 or later … … 16 16 } 17 17 18 define('REAL_TIME_VALIDATION_ADDON_VERSION', '1.0. 3');18 define('REAL_TIME_VALIDATION_ADDON_VERSION', '1.0.4'); 19 19 20 20 add_action('gform_loaded', array('GF_Real_Time_Validation_AddOn_Bootstrap', 'load'), 5); … … 39 39 return GFRTVAddOn::get_instance(); 40 40 } 41 42 // Translate direction43 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.