Form bypasses my JS validation and submits even on validation failure

  • ronaldlthomas
    Asked on April 4, 2014 at 2:46 PM

    I've tried several different methods to validate my form using javascript but regardless of what I try the form submits anyway, even after the alert pops up telling me that the form submission is invalid.

    I've used a method inside the form tag

    <form ... onDISABLEDsubmit="return isNumeric()">

    with this function

    function isNumeric() { var numericExpression = /^[0-9]+$/; var area = document.getElementById('input_18_area').value; if(area.match(numericExpression)){ return true; } else { alert(numbers only please); return false; }}
    I've also tried adding <button ... onDISABLEDclick="isNumeric(document.getElementById('numbers'), 'not submitted')"></button> input_8.onDISABLEDclick=function() { var vemail = document.getElementById('input_4').value; if (vemail === "" || vemail === " ") { alert('Please correct the errors'); return false; } else { return true; } }; Any thoughts on what I might be doing wrong?
  • KadeJM
    Replied on April 4, 2014 at 4:34 PM

    Looking at your form I think what's going wrong as that the custom js you are using is probably conflicting with the form's own js libarary so it is causing it to break and not work.

    I see the code you are using but what you are trying to do and validate with it is a bit sketchy. However, It could probably work so long as you are using the form's source code on your website which it I believe you are doing already it seems. So I think it will just require some further tweaking.

    Can you please provide us with further details about what you are doing and we'll do what we can on our end to help aid you with fixing this.