diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index 4a94a6df5..60e0a0a4b 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -22,6 +22,11 @@ class App.ControllerGenericNew extends App.ControllerModal object = new App[ @genericObject ] object.load(params) + # validate form using HTML5 validity check + element = $(e.target).closest('form').get(0) + if element && element.reportValidity && !element.reportValidity() + return false + # validate errors = object.validate() if errors @@ -70,6 +75,11 @@ class App.ControllerGenericEdit extends App.ControllerModal params = @formParam(e.target) @item.load(params) + # validate form using HTML5 validity check + element = $(e.target).closest('form').get(0) + if element && element.reportValidity && !element.reportValidity() + return false + # validate errors = @item.validate() if errors