I'm trying to validate a form before submitting to a external URL:
<form name="form" novalidate ng-submit="form.$valid && alias != ''" method="POST" action="https://sis-t.redsys.es:25443/sis/realizarPago">
<input name="alias" ng-change="updateData(alias)" ng-model="alias" type="text" class="form-control validate" placeholder="{{ translates.alias_desc }}" required>
</form>
You can write your own directive which will prevent default behavior of submitting form. You can do it like this:
Note,
$timeout
wrapper is necessary to force call$digest
and set$dirty
and$submitted
states to form (if you use classesng-dirty
andng-submitted
for form validation).After you could use this directive like this:
Demo: http://plnkr.co/edit/1WYRRT3k4YkjodOD7ul3?p=preview