Skip to content

Instantly share code, notes, and snippets.

@jennlee20
Last active January 31, 2023 22:20
Show Gist options
  • Save jennlee20/a3ba05b7c8d070840dd64287aa053200 to your computer and use it in GitHub Desktop.
Save jennlee20/a3ba05b7c8d070840dd64287aa053200 to your computer and use it in GitHub Desktop.
/*
* JS snippet to match two fields value as same
* Example: Email and Confirm Email need to be same
* Placement: Place the following code in your form -> Settings & Integrations -> Custom CSS/JS -> Custom Javascript BOX
*/
var $email = $form.find('input[name=email]'); // Name of the first Email Address
var $confirmEmail = $form.find('input[name=confirm_email]'); // Name of the Confirm Email Address
$confirmEmail.on('blur', function() {
if($(this).val() != $email.val()) {
alert('Email not matching');
// Or you can show the custom message somewhere
}
});
// Additional code to check if user fixed the type in the primary email
$email.on('blur', function() {
if($confirmEmail.val() && $(this).val() != $confirmEmail.val()) {
alert('Email not matching');
// Or you can show the custom message somewhere
}
});
/*
* Check how advanced customization works here
* https://wpmanageninja.com/docs/fluent-form/field-types/time-date/#advanced_configaration
* You can use the following snippets in the "Advanced Date Configuration" box of your date element settings
* - You can use these settings as combined to
* - you can use any flatpickr options - https://flatpickr.js.org/examples/
*/
/*
* Allow only future dates
*/
{
minDate: "today"
}
/*
* Allow only from today and 14 days from now
*/
{
minDate: "today",
maxDate: new Date().fp_incr(14) // 14 days from now
}
/*
* Disabling range(s) of dates:
*/
{
dateFormat: "Y-m-d",
disable: [
{
from: "2020-08-01",
to: "2020-08-01"
},
{
from: "2020-09-01",
to: "2020-10-01"
}
]
}
// to reset google recaptch if validation failed
$('body').on('fluentform_submission_failed', function(){ grecaptcha.reset() });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment