Search Posts

Category: forms

How to get an angular form to update after set value from dev console injected code?

how to How to get an angular form to update after set value from dev console injected code? So, I’m looking to automated some functions on a website that is not mine. I’m doing so with injected javascript code in the console so its all client side and several forms need to be triggered. No problem in standard javascript / html forms, but both react and angular apps, this poses a problem. For angular, they […]

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 […]

HTML form in ng-if environment

Structure of my app is like following: <div class=”parent”> <div class=”child” ng-if=”isShown”> <div class=”child-view-1″ ng-if=”!isShown”> </div> <div class=”child-view-2″ ng-if=”isShown”> </div> </div> </div> Inside child-view-2 I have form element, and of course, it is undefined in controller, probably beacuse of ng-if (as it creates child scope). isShown variable just switches divs from child-view-1 to child-view-2. What do you suggest, how can I make form visible all time in controller? Source: AngularJS

How to reset form after submission in Angular?

I have a two field form and i want to just change the tab while submission of form and the problem is since the page is not reloading the form remains as same as previously entered. Here is my form <form name=”userForm” ng-submit=’manageBed.addBed(bedData);’ ng-hide=”manageBed.loader”> manageBed is the controller tried with $scope.userForm.$setPristine(); and also clearing bedData this.bedData={}; in controller gives that required field error. this.addBed = function(bedData) { Admin.addBed(this.bedData).then(function(data) { if (data.data.success) { app.loader = true; […]

AngularJS 1.6.8: Unable to submit form and display success message

I have a simple query submission form with name, email and query fields and a component with a controller function having the submit function to submit the form. I am using ng-submit directive in the <form></form> tag to submit the user input and display a success message on submission. below is the code for the respective files. contact.html <div ngController=”contactController as vm”> <div class=”heading text-center”> <h1>Contact Us</h1> </div> <div> <form class=”needs-validation” id=”contactForm” novalidate method=”post” name=”vm.contactForm” […]

How to insert new data row in table when clicked on add button with AngularJS

Roadmap: I have a form with one row of some fields and select menus. So, when I insert all the data in that form and press ADD ( + ) button, I want that information automatically added as a row in the table defined below the form. My Form: <div class=”form-inline”> <!– location form –> <div class=”form-group”> <input type=”text” placeholder=”Landmark” ng-model=”company.location.landmark”/> </div> <div class=”form-group”> <input type=”text” placeholder=”Street 1″ ng-model=”company.location.street1″/> </div> <div class=”form-group”> <input type=”text” placeholder=”Street […]

Angular Form submit button only fires on second click

I’m building a small webpage that does some queries to an API. The query happens when the submit button is hit, if all entered data is valid. However at some point when I was adjusting the form from a set of separate elements (textbox, selectbox, button), I started having to hit “Search” once, and then hit it again for the function to fire. What is going on/how do I fix this? HTML: <div id=”search” class=”centerWrapper”> […]

ng-submit called twice in angular form

I have gone through several questions regarding this issue, but none solved my issue I am using a form in which two submit type button calling same function. One button is send an extra variable with it on ng-click. when I submit my function is being called twice. I am using an approach told in the second answer of this question (mostly voted) I have not included controller as ng-controller in HTML <form ng-submit=”SaveContent(Form)”> <button […]

AngularJs input field validation

I have an input field on my HTML page and I want to put some validations on it. Limit the number of characters that the field can hold (say 6 maximum). The field can only contain numeric characters. the field is disabled if it does not contain 6 Zeros (000000). The field should be editable if it contains 6 Zeros (000000). <input type=”text” ng-model=”testfield” placeholder=”XXXXXX” ng-maxlength=”6″ ng-disabled=”testfield !=’000000′” ng-required=”testfield ==’000000′” ng-pattern=”/^[0-9]{6}$/”> Source: AngularJS

AngularJS process form on form click

I’m trying to submit a form when user clicks on any part of the form, and then process it using AnglujarJS. Here’s how I tried doing it: <form ng-click=”submit()” ng-app=”MyApp” ng-controller=”MyCtr”> <input type=”text” ng-model=”my_val” name=”my_val” value=”0″ style=”display: none”/> </form> var app = angular.module(‘MyApp’, []); app.controller(‘MyCtr’, function($scope) { $scope.submit = function() { $scope.my_val; // This is undefined }); }; }); The problem is that $scope does not have form values. If I replace ng-click with ng-submit, […]

Next Page »