-1

I have a html form with multiple textboxes. Each textbox can accept only integers.

I am using dojo NumberTextBox to validate this. But the problem is, even if a textbox is in error, only an error tooltip is displayed but the user can still press the submit button.

Is there a way to disable the submit button if any textbox is in error?

cmn
  • 383
  • 3
  • 12
  • 2
    Are the elements wrapped in a dojo Form or just a regular HTML form? The dojo form uses the kind of validation you want. – Chris Hayes Dec 19 '13 at 06:04
  • Changed to dojo form and it worked. Thanks Chris.. – cmn Dec 19 '13 at 06:13
  • duplicate question - http://stackoverflow.com/questions/4227043/how-do-i-cancel-form-submission-in-submit-button-onclick-event (how to prevent submission). – Guy Dafny Dec 19 '13 at 06:31

1 Answers1

1

You need to have a custom submit button.

<button onClick='submitForm("NAME OF FORM")' value='Submit'>

<Script>
function submitForm(name) {
  var bad = 0;
 for(Loop through values) {
  if(isNaN(num)) {
     bad = 1;
  }
 }
 if(bad==0) {
    document.forms[name].submit();
 }
}
</script>
Alan Bowen
  • 1,028
  • 1
  • 9
  • 8