'Cancel Form without validation
I have an HTML Form which has two Buttons of the type "submit". One for submitting the form and one for cancelling the form.
To validate the input, I added a event listener, which reacts when somebody submits the form:
$("form").submit(function (e) {
if (textboxContainsValues){
return true:
}
else false;
});
My problem is, when I click on "Cancel" (abbrechen), it also goes into the event listener and checks the textboxes for values.
Is there a way to distinguish those two actions with my above listener?
thanks in advance
Solution 1:[1]
As pointed out in the comments you could either simplify your function to just return textboxContainsValues; or even better use type="button" instead of type="submit" on your cancel button.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dmitrij Kiltau |

