Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-28987

Javascript validation doesn't check correct fields

XMLWordPrintable

    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE
    • wip-mdl-28987
    • Hide

      Test 1:
      1. create a lesson activity
      2. add question page for multiple choice answer
      3. Fill all the fields except one "required" field
      4. Submit form
      5. Make sure required message is display and form should not be submitted. (Try keep an eye on url, it should not change)
      6. Try submit again (2-3 times) and form should not be submitted and "required" error should be visible.
      7. Now fill all fields and try submit, form should be submitted.
      8. Create a new multichoice question and fill all fields except one "non-required" field and make sure it gets submitted.

      Test 2:
      1. Login as admin
      2. Create a new course
      3. Fill all fields, except "course summary"
      4. Make sure form should be submitted.

      Note:
      1. Check this on IE, FF, Opera and Chrome to make sure it's working fine.
      2. Make sure to test it on 20 and 21 branch as well.

      Show
      Test 1: 1. create a lesson activity 2. add question page for multiple choice answer 3. Fill all the fields except one "required" field 4. Submit form 5. Make sure required message is display and form should not be submitted. (Try keep an eye on url, it should not change) 6. Try submit again (2-3 times) and form should not be submitted and "required" error should be visible. 7. Now fill all fields and try submit, form should be submitted. 8. Create a new multichoice question and fill all fields except one "non-required" field and make sure it gets submitted. Test 2: 1. Login as admin 2. Create a new course 3. Fill all fields, except "course summary" 4. Make sure form should be submitted. Note: 1. Check this on IE, FF, Opera and Chrome to make sure it's working fine. 2. Make sure to test it on 20 and 21 branch as well.

      MDL-27728 provided a way to skip over elements the formslib failed to find. While this stops the javascript dying and submitting the form erroneously, the form never performs validation on editor type elements.

      This is because editor elements we want to check are named name="<elementname>[text]". The javascript validation is only looking for <elementname>.

      My proposed fix for this is when generated the validation js, to check if the element type is 'editor' and if so, to append [text] onto the name used in the JS.

      Replication instructions:
      1. Try editing a form with a editor (one that's required).
      2. Submit the form after having filled out all required fields except a required editor field.
      3. Form should not be submitted and display error message ("Required") on the editor field.
      4. If the page POST'ed at all when submitted, client side validation failed.

      When this fails, the form does submit and the server side validation (if any) catches the missing required field(s) and prevents the form submitting.

            rajeshtaneja Rajesh Taneja
            aolley Adam Olley
            Marina Glancy Marina Glancy
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Sam Hemelryk Sam Hemelryk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.