• Resolved ChristianEllsworth

    (@christianellsworth)


    Hi,
    I’m created custom validation using the before_submit function in the javascript section.
    Is there anyway to stop the form from submitting from within this function?? When I submit the form I see the alert and then the form gets submitted.

    Here is my code

    function before_submit() {
      if (!jQuery(".prettyRadiobuttons input").is(":checked")) {
          alert("Radio Buttons not checked");
          return false;
        }
    }

    Thanks,
    Christian

    https://wordpress.org/plugins/form-maker/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor webdorado

    (@webdorado)

    Dear Christian,

    Please add the following code instead of the one you use:

    function fm_validation() {
        if (!jQuery(".prettyRadiobuttons input").is(":checked")) {
              alert("Radio Buttons not checked");
        }
        else {
             check_required12('submit', 12);
        }
    }

    Where 12 should be replaced with your form Id.

    In addition you should replace the standard Submit button with a custom one typing in the following an an OnClick function: fm_validation()

    Thread Starter ChristianEllsworth

    (@christianellsworth)

    Thanks that worked!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Anyway to stop form submission with javascript’ is closed to new replies.