Skip to content

Commit

Permalink
Revert "Fix registration code form button from disabling on invalid e…
Browse files Browse the repository at this point in the history
…ntry"

This reverts commit 01cf7d7.
  • Loading branch information
lmerchant committed Feb 14, 2025
1 parent 01cf7d7 commit b390ece
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
3 changes: 1 addition & 2 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,7 @@ def get_ajax_check_ffq_code(ffq_code):
except: # noqa
return_val = False

# Convert to JSON for returning to JavaScript call
return json.dumps(return_val)
return return_val


def _associate_sample_to_survey(account_id, source_id, sample_id, survey_id):
Expand Down
40 changes: 22 additions & 18 deletions microsetta_interface/templates/nutrition.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,44 @@
preventImplicitSubmission(form_name);
preclude_whitespace('#ffq_code');
function handleSubmit() {
// TODO go to page since form validated
console.log('submitted form')
};
$("form[name='" + form_name + "']").on('submit', function() {
document.getElementById("ffq_code_button").disabled = true;
});
// Validate the registration form for a valid
// registration code using the jQuery validation plugin.
// If the form is not valid, the messages are displayed
// Initialize form validation on the registration form.
// It has the name attribute "registration"
$("form[name='" + form_name + "']").validate({
// Specify validation rules
rules: {
// The key is the form input field name attribute and the validation rules
// are defined in the value object
// The route check_ffq_code_valid returns
// either true or false
// The key name on the left side is the name attribute
// of an input field. Validation rules are defined
// on the right side
ffq_code: {
required: true,
remote: {
url: "/check_ffq_code_valid",
}
},
submitHandler: function (form) {
form.submit();
}
},
submitHandler: function (form, event) {
// prevent multiple submissions
document.getElementById("ffq_code_button").disabled = false;
handleSubmit(form);
},
messages: {
ffq_code: "{{ _('Your registration code is not in our system or has already been used. Please try again.') }}",
},
});
});
/*
function updateButtonState(ffq_code_value) {
if(ffq_code_value != "") {
document.getElementById("ffq_code_button").disabled = false;
} else {
document.getElementById("ffq_code_button").disabled = true;
}
}
*/
function openCodePanel() {
document.getElementById('add_code_container').style.display = '';
document.getElementById('add_code_card').style.display = '';
Expand Down Expand Up @@ -212,7 +216,7 @@
</div>
</div>
<div class="col-12 text-center mt-4">
<button type="submit" class="btn btn-blue-gradient" name="ffq_code_button" id="ffq_code_button">{{ _('Register FFQ') }}</button>
<button class="btn btn-blue-gradient" name="ffq_code_button" id="ffq_code_button">{{ _('Register FFQ') }}</button>
</div>
</div>
</div>
Expand Down

0 comments on commit b390ece

Please sign in to comment.