MediaWiki:Gadget-FormCheck.js

From Tsadra Foundation Advanced Contemplative Scholarships
Revision as of 07:34, 21 May 2024 by Jeremi (talk | contribs) ((by SublimeText.Mediawiker))

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function checkForm() {
    if( $('select[name="retreattype[]"]').val() === 'Three-year retreat') {
        if( $('.MustField, .ThreeMustField').filter(function() { return this.value === ''; }).length === 0 ) {
            console.log("All filled, setting status to 'Complete'.");
            $('input[name="status"]').val("Complete");
        } else {
            console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
            $('input[name="status"]').val("Saved");
        }
    } else if( $('select[name="retreattype[]"]').val() === 'Solitary hermitage') {
        if( $('.MustField, .SolMustField').filter(function() { return this.value === ''; }).length === 0 ) {
            console.log("All filled, setting status to 'Complete'.");
            $('input[name="status"]').val("Complete");
        } else {
            console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
            $('input[name="status"]').val("Saved");
        }
    } else {
        console.log("Retreat type not set." + $('select[name="retreattype[]"]').val());
    }
}
if( $('input[name="status"]').val() === 'Complete') {} else {
    jQuery(document).ready( checkForm() );
    $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').on( "keyup", checkForm() );
}