Search Posts

Category: validation

Custom validation in angularjs compare two dates

I have two fields hiring_date and expiry_date I am using angular UI datepicker. I want to validate the form if hiring date is greater than the expiry date This is my code: logic is okay but how can I set this to form error as false <small ng-show=”formStep1.expiry_date.$invalid && formStep1.expiry_date.$touched ” class=”errorMsg “> Please enter valid date (YYYY-MM-DD).</small> <small ng-show=”formStep1.expiry_date.$modelValue < formStep1.hiring_date.$modelValue” class=”errorMsg “> Expiry Date should not be a older than Target Hiring Date.</small> […]

Revalidate form when removing elements dynamically in AngularJS with AngularJS Material

I have a form made with AngularJS Material elements in which elements can be added and deleted dynamically. Each of these elements is formed by a md-autocomplete and an input. Both fields are required. I have two problems, the first is that the input is not validated correctly, the second problem is that when a field is deleted, the form is not revalidated, so the form will be considered invalid even if the elements that […]

Angular Schema Form – "required" not working select and checkbox fields

I’m new to Angular Schema Form and having some issues with select and checkbox fields required validation. Under $scope.schema I have the select field named designation: “designation”: { “title”: “Designation”, “type”: “select”, “default”: undefined } $scope.form (declaring designation and agreeTerms): { “key”: “designation”, “type”: “select”, “title”: “Designation”, “titleMap”: [ { value: undefined, name: “Select a designation” }, // first value { value: “Andersson”, name: “Andersson” }, { value: “Johansson”, name: “Johansson” }, { value: “other”, […]

how to validate fields added dynamically on submit in angular js using angular form validation

I am trying to add fields dynamically by appending it in an object array. now I want to validate these field which are added dynamically to not be empty on submit. when I make $scope.submitted = true in js controller , if I have added three fields and the last field is empty the error message is shown for all the three fields. I want it to be shown on that particular empty field only. […]

AngularJS – max validation not working on time input

I am writing an app with AngularJS 1.5.3. I have an input form with a time input box. I need to have validation on the box such that the user cannot pick a time in the future. Here is a snippet: <div ng-controller=”myController as accvm”> <form name=”accvm.addForm” novalidate> <div class=”item item-input” ng-class=”{ ‘has-error’ : accvm.addForm.time.$invalid }”> <span class=”input-label”>’Time'</span> <input name=”time” type=”time” id=”timeInput” max=”{{ | date:’HH:mm’ }}” ng-model=”” ng-change=”accvm.timeChange()” style=”text-align: right” required /> </div> </form> […]

validate one ng-include inside a form

how to validate one ng-include inside a form How can I validate one ng-include at a time, <form name=”myform” ng-submit=”validateData()” novalidate=”novalidate”> <div> <div ng-include=”customtemplate”></div> </div> <div class=”center”> <input class=”btn buttonNewRequest” type=”submit” id=”submit” value=”Submit” /> <input class=”btn buttonNewRequest” type=”button” id=”reset” value=”Reset” /> </div> </form> I am using the two different templates dynamically using customtemplate, my problem is here, it’s validating both template same time. So how to restrict one template for validation at a time. Please […]

how to apply validation to dynamically added field to form

how to how to apply validation to dynamically added field to form I have form with two fields and until those fields are filled with some text my submit button will be disabled but now if i add third field dynamically angular JS will not support validation for the third field which is added dynamically. link <button ng-click=”adddynamicfield()”>add dynamic field<button> <form name=”dynamicform” novalidate=”true”> <input type =”text” dynamic-name name=”name” ng-model=”” required> <input type =”text” dynamic-name […]

Validate form only if one or more field contains a number, Angular.JS

how to Validate form only if one or more field contains a number, Angular.JS I want to validate an order form with Angular.JS. The form dynamically adds input fields depending on how many products there are. The dynamically added input fields are used to determine how many products the user wants to purchase. I want the form to validate if either one of the fields has a value of minimum 1 (the user has to […]

Enter a negative number in the input number field and validation with ng-pattern-restrict

I’m having problems with ng-pattern-restrict I have an input number field with ng-pattern-restrict = “^. {0,13}? $” But when I wanted to enter a negative number, I tried two ways: ng-pattern-restrict = “^ – d {0,13}? $”: This way, the negative number is good, but it does not allow you to enter positive numbers, because the character at the start must be (-) ng-pattern-restrict = “^ d {0,13} ( – d {0,13})? $”: this method […]

Next Page »