Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions js/formidable.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ function frmFrontFormJS() {
* @return {Array} Errors.
*/
function validateForm( object ) {
let errors, n, nl, fields, field;

errors = [];
let errors = [];

const vanillaJsObject = 'function' === typeof object.get ? object.get( 0 ) : object;

Expand All @@ -201,10 +199,8 @@ function frmFrontFormJS() {
}
);

fields = jQuery( object ).find( 'input,select,textarea' );
if ( fields.length ) {
for ( n = 0, nl = fields.length; n < nl; n++ ) {
field = fields[n];
vanillaJsObject?.querySelectorAll( 'input,select,textarea' ).forEach(
field => {
if ( '' === field.value ) {
if ( 'number' === field.type ) {
// A number field will return an empty string when it is invalid.
Expand All @@ -215,14 +211,14 @@ function frmFrontFormJS() {
if ( ! isConfirmationField ) {
// Allow a blank confirmation field to still call validateFieldValue.
// If we continue for a confirmation field there are issues with forms submitting with a blank confirmation field.
continue;
return;
}
}

validateFieldValue( field, errors, true );
checkValidity( field, errors );
}
}
);

// Invisible captchas are processed after validation.
// We only want to validate a visible captcha on submit.
Expand Down