Skip to content

Commit

Permalink
Survey Module Validation Fix (#9116)
Browse files Browse the repository at this point in the history
Fixes bug where when emailing a survey, if you enter mismatch emails the Email button is disabled but the form is not sent out, but no error message displayed.

Resolves #9086
  • Loading branch information
sruthymathew123 committed Apr 30, 2024
1 parent c8f8320 commit a3cd751
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modules/survey_accounts/js/survey_accounts_helper.js
Expand Up @@ -13,21 +13,21 @@ $(window).resize(function(){
});

$(document).ready(function () {

$('#email_survey').attr('disabled','disabled');
// Handles cases where there was an error on the page and we're resubmitting
var email2 = $("input[name=Email2]").val();
var email = $("input[name=Email]").val();
if (email && email2) {
if (email.length > 0 && email2.length > 0 && email == email2)
{
$('#email_survey').removeAttr('disabled');
} else {
$('#email_survey').attr('disabled','disabled');
}
}
// Reset Test_name so that the template can be loaded by ajax below
$("select[name=Test_name]").val("");

$('#Email2').change (function() {
$('#Email, #Email2').change (function() {
var email2 = $("input[name=Email2]").val();
var email = $("input[name=Email]").val();
if (email.length > 0 && email2.length > 0 )
Expand All @@ -39,7 +39,10 @@ $(document).ready(function () {
$('#create_survey').removeAttr('disabled');
$('#email_survey').attr('disabled','disabled');
}

if (email.length > 0 && email2.length > 0 && email !== email2)
{
$("#email-error").show().html("Emails do not match");
}
} );
$("#emailData").click(function(){
$("<input>").attr({
Expand All @@ -64,7 +67,7 @@ $(document).ready(function () {
pscid: $("input[name=PSCID]").val(),
VL: $("select[name=VL]").val(),
TN: $("select[name=Test_name]").val(),
Email: $("input[name=Email").val(),
Email: $("input[name=Email]").val(),
Email2: $("input[name=Email2]").val()
},
function(result) {
Expand All @@ -77,6 +80,8 @@ $(document).ready(function () {
$("#email-error").html(result.error_msg);
}
else {
// Reset Error messages when all good
$("#email-error").html('');
$("#emailModal").modal();
}
}
Expand Down

0 comments on commit a3cd751

Please sign in to comment.