PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | js/formidable.js +53 -5 6.5.26.7 View file →
@@ -201,11 +201,12 @@
201 201 $form.find( 'a.frm_save_draft' ).css( 'pointer-events', '' );
202 202 }
203 203
204 204 function validateForm( object ) {
205 - var r, rl, n, nl, fields, field, value, requiredFields,
206 - errors = [];
205 + var errors, r, rl, n, nl, fields, field, requiredFields;
207 206
207 + errors = [];
208 +
208 209 // Make sure required text field is filled in
209 210 requiredFields = jQuery( object ).find(
210 211 '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
211 212 ).filter( ':not(.frm_optional)' );
@@ -222,11 +223,18 @@
222 223 fields = jQuery( object ).find( 'input,select,textarea' );
223 224 if ( fields.length ) {
224 225 for ( n = 0, nl = fields.length; n < nl; n++ ) {
225 226 field = fields[n];
226 - if ( '' !== field.value ) {
227 - validateFieldValue( field, errors );
227 + if ( '' === field.value ) {
228 + if ( 'number' === field.type ) {
229 + // A number field will return an empty string when it is invalid.
230 + checkValidity( field, errors );
231 + }
232 + continue;
228 233 }
234 +
235 + validateFieldValue( field, errors );
236 + checkValidity( field, errors );
229 237 }
230 238 }
231 239
232 240 errors = validateRecaptcha( object, errors );
@@ -234,8 +242,33 @@
234 242 return errors;
235 243 }
236 244
237 245 /**
246 + * Check the ValidityState interface for the field.
247 + * If it is invalid, show an error for it.
248 + *
249 + * @param {HTMLElement} field
250 + * @param {Array} errors
251 + * @returns
252 + */
253 + function checkValidity( field, errors ) {
254 + var fieldID;
255 + if ( 'object' !== typeof field.validity || false !== field.validity.valid ) {
256 + return;
257 + }
258 +
259 + fieldID = getFieldId( field, true );
260 + if ( 'undefined' === typeof errors[ fieldID ]) {
261 + errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
262 + }
263 +
264 + if ( 'function' === typeof field.reportValidity ) {
265 + // This triggers an error pop up.
266 + field.reportValidity();
267 + }
268 + }
269 +
270 + /**
238 271 * @since 5.0.10
239 272 *
240 273 * @param {object} element
241 274 * @param {string} targetClass
@@ -508,9 +541,9 @@
508 541 }
509 542
510 543 // Function to change the color of a select element
511 544 changeSelectColor = function( select ) {
512 - if ( hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) {
545 + if ( select.options[select.selectedIndex] && hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) {
513 546 select.style.setProperty( 'color', textColorDisabled, 'important' );
514 547 } else {
515 548 select.style.color = '';
516 549 }
@@ -1475,8 +1508,21 @@
1475 1508 );
1476 1509 }
1477 1510 }
1478 1511
1512 + function enableSubmitButtonOnBackButtonPress() {
1513 + window.addEventListener( 'pageshow', function( event ) {
1514 + if ( event.persisted ) {
1515 + document.querySelectorAll( '.frm_loading_form' ).forEach(
1516 + function( form ) {
1517 + enableSubmitButton( jQuery( form ) );
1518 + }
1519 + );
1520 + removeSubmitLoading();
1521 + }
1522 + });
1523 + }
1524 +
1479 1525 return {
1480 1526 init: function() {
1481 1527 maybeAddPolyfills();
1482 1528
@@ -1522,8 +1568,10 @@
1522 1568 setSelectPlaceholderColor();
1523 1569
1524 1570 // Elementor popup show event. Fix Elementor Popup && FF Captcha field conflicts
1525 1571 jQuery( document ).on( 'elementor/popup/show', frmRecaptcha );
1572 +
1573 + enableSubmitButtonOnBackButtonPress();
1526 1574 },
1527 1575
1528 1576 getFieldId: function( field, fullID ) {
1529 1577 return getFieldId( field, fullID );