152
rated 0 times
[
153]
[
1]
/ answers: 1 / hits: 26608
/ 9 Years ago, tue, september 1, 2015, 12:00:00
I have created a form in ionic-angular and applied validations on it.Validations are not working properly.Even all the fields are empty on click of submit button it calls controller function.
Please help me to solve this issue.
html code
<ion-pane>
<ion-header-bar class=bar-stable>
<h1 class=title>Register</h1>
</ion-header-bar>
<ion-content >
<form name=register ng-submit=submitDetails(user) novalidate=>
<div class=list>
<label class=item item-input item-floating-label style=position:relative;>
<span class=input-label>First Name</span>
<input type=text placeholder=First Name ng-model=user.firstName ng-required=true>
<p ng-show=user.firstName.$invalid && !user.firstName.$pristine class=help-block>You name is required.</p>
</label>
<label class=item item-input item-floating-label>
<span class=input-label>Email</span>
<input type=email placeholder=Email ng-model=user.email ng-required=true>
<p ng-show=user.email.$invalid && !user.email.$pristine class=help-block>Enter a valid email</p>
</label>
<label class=item item-input item-floating-label>
<span class=input-label >Phone no</span>
<input type=number placeholder=Phone No ng-model=user.phone ng-minlength=10 ng-maxlength=10 ng-required=true>
<span class=help-block ng-show=user.phone.$error.required || user.phone.$error.number>Valid phone number is required</span>
<span class=help-block ng-show=((user.phone.$error.minlength || user.phone.$error.maxlength) && user.phone.$dirty) >phone number should be 10 digits</span>
</label>
<input type=submit class=button button-royal value=register>
</div>
</form>
</ion-content>
</ion-pane>
Controller code
chatApp.controller('RegisterCntrl', function($scope, $stateParams) {
$scope.user={};
$scope.submitDetails=function(user){
alert(user+user.firstName);
};
});
More From » angularjs