Initially, my form displays an error message that functions correctly. I have now encountered a dilemma while attempting to customize this error message based on user input gathered earlier in the form:
if (thing is true) {
$(this).parents("table:first")
.prop("disabled",true)
.css({'background-color' : 'lightgray'})
.after("<font color = red id=error3><strong>*</strong> Please check that your start and end dates are between June 15, 2018 and November 30, 2019. The Start Date may not be greater than the End Date.</font>");
}
I aim to modify the error message by integrating dates provided by the user in previous sections of the form. Despite using concatenation, I am faced with the following challenge:
if (thing is true) {
// example dates provided by user
cysd = $("#id_currentyearstartdate").val();
cyed = $("#id_currentyearenddate").val();
// assuming cysd is January 1, 2018 and cyed is December 31, 2018
$("input#next-submit-button")
.prop("disabled",true)
.css({'background-color' : 'lightgray'})
.after("<font color = red id=error2><br>Please resolve any errors above before continuing. <br><strong>*</strong> Check that your start and end dates are between </font>" + cysd + "<font color = red id=error2> and </font>" + cyed + "<font color = red id=error2>. The Start Date may not be greater than the End Date.</font>");
The issue arises from the fact that the original error message contained only one message under the font ID "error2," allowing easy additions or removals based on specific conditions.
I am struggling to incorporate the variable values within the actual text of the error message or the font tag itself. This way, when id=error2 is referenced, it encompasses the entire statement "Please check that your start and end dates are between January 1, 2018 and December 31, 2018. The Start Date may not be greater than the End Date."