Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to put normal validation in crud table grid based on angular..
My code is working for add operation but not for edit one because for add and delete I am using the same modelname.
My code for add one is below:

<input placeholder="Group Name" required ng-model="grp.GroupName" name="grpname" ng-init="grp.GroupName='Group Name'" ng-maxlength="100" ng-minlength="3" />

ng-show="groupPage.grpForm.grpname.$error.required && groupPage.grpForm.grpname.$dirty && !groupPage.grpForm.grpname.$pristine ">Group Name is Required


ng-show="groupPage.grpForm.grpname.$error.minlength">Group Name is too short.


ng-show="groupPage.grpForm.grpname.$error.maxlength">Group Name is too long.

And edit code is below:-

{{grp.GroupName}}
<input placeholder="Group Name" required ng-model="grp.GroupName" ng-show="grp.editMode == true" name="grpeditname" ng-maxlength="100" ng-minlength="3" />
{{grp.GroupName}}

ng-show="groupPage.grpForm.grpeditname.$error.required && groupPage.grpForm.grpeditname.$dirty && !groupPage.grpForm.grpeditname.$pristine">Group Name is Required


ng-show="groupPage.grpForm.grpeditname.$error.minlength">Group Name is too short.


ng-show="groupPage.grpForm.grpeditname.$error.maxlength">Group Name is too long.


The code for edit is not working Its $scope.Valid is coming as false...it should be true in default case.
I did research on it and found that its due to grp.groupname...groupname is empty for add case...and when i do edit it creating trouble though edit groupname is nt null..both falls in same form...Required field validator and min max length error is also nt displayed in second case..How to solve such case..
Posted
Updated 8-Sep-15 4:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900