angularjs - How to prevent Angular form from being sent to a php file (method="post") when invalid? -
i guess in such case default of angular add ng-disabled submit button. if so, user warned errors in each input, errors shown instantly. there way show errors (through function in controller or other way), after onclick, without having form submitted , send php if invalid?
html
<form name="myform"> <input type="text" name="textfield" ng-model="textfield"/> <md-button type="button" class="btn-width-medium md-raised md-primary" ng-click="validateform()"> save </md-button> </form
controller :
.controller("controller",function($scope){ $scope.validateform = function(){ // validation here // if valid // submit form - post data // else invalid // show message , return }; });
Comments
Post a Comment