I'm trying to do a bit of form validation in angular before I submit it. I'm using the ng-submit in my form, but no matter what I do, the form still submits... Here is what I currently have:
Rails:
<%= form_tag("/createListing", "ng-submit" => "formvalidation($event)") do %>
... form contents in here
<button ng-disabled="!agree_terms" value="Start" type="submit">Submit</button>
<% end %>
Javascript:
$scope.formvalidation = function() {
var errors = validationService.dosomevalidation();
if (errors.length === 0) {
$event.target.submit();
} else {
$scope.errors = errors;
return false;
}
}
My thought process is kind of how I would do it jQuery or vanilla javascript. Any ideas why the form would still submit?
Thanks in advance.