webadvanced / ng-remote-validate Goto Github PK
View Code? Open in Web Editor NEWAjax & server side validation for Angularjs
License: Apache License 2.0
Ajax & server side validation for Angularjs
License: Apache License 2.0
Hey, @valmont nice plugin. However, i've an issue with an input of type email;
when i change to
type="text"
it works. Is this normal behaviour?
I'm working on a sign-up flow where ng-model for the validating input field is populated on a previous screen before the is added to DOM.
When the input field is shown, the current pre-populated value is not sent to the server, onload, can this be done?
Try my best,I could't find any answer in the Internek suitable for me,could you please give me a demo?
If we come to edit mode. Have there for example 'abcd' and enter some 'abcde' and then remove e -> we get error validation because this value already exists. It's wrong as for me. How to prevent this?
Setup: AngularJS v1.2.27
In my application I have a couple of fields using the remote validation directive. If I enter some invalid text and then empty the input box, the ng-invalid-ng-remote-validate class is not removed (even if the ng-dirty class is removed and ng-pristine is added).
Should these lines be expanded and return with a setValidation() call?
bower.json should specify a dependency on Angular so that utilities like main-bower-files can ensure that Angular is loaded before ng-remote-validate.
(Until then, a manual override of the dependencies key is necessary in the bower.json of any project using this package.)
Is it possible to fire the validation manualy if an other element (e.g. a radio group button) has changed? How can I do that?
Thank you
Hello. When first time enter "test" in my input, validation work fine, but when I again enter "test" in input, i get validation for word "tes", because validation for word "test" is taken from the cache but after this request for "tes" ends and replace validation for "test".
I think you need to add a check in function "handeChange" in this section of code.
if (cache[value]) {
return setValidation( cache[ value ], true );
}
Something like this:
if (cache[value]) {
if (request) {
$timeout.cancel(request);
}
return setValidation( cache[ value ], true );
}
Hi there,
this does not seem to work:
<input type="email" class="form-control" required ng-model="order.account.email" ng-remote-validate="[AFTERCARE + '/misc/email']" ng-remote-method="POST">
My project has AFTERCARE
assigned to the $rootScope
and print this out works, but inside the attribute it throws an error (ReferenceError: AFTERCARE is not defined
).
Any idea?
When the API call returns an error there is no way to handle it.
We can use the custom validation callback to inject extra information into the validation callback, but it would be good if the current controller/route and input name could be included by default
Hi,
I tried using your directive, but can't seem to get the Custom call back working:
HTML:
<input type="email" name="email" ng-model="user.email" ng-remote-validate="{ '/user/checkEmailValid' : 'uniqueEmail'}" />
Controller:
var registrationApp = angular.module('registrationApp',['ui.utils','remoteValidation']);
registrationApp.controller('RegistrationCtrl', function ($scope, $http, $window) {
$scope.emailSetArgs = function( val, el, attrs, ngModel ) {
return { test: val };
};
});
It is always sent as { value: val }
instead of { test: val }
. I was thinking of sending the string straightaway without any JSON array.
Am I doing anything wrong in my code?
I'm using this to validate an email field remotely.
Looking at the console, the HTTP.GET works exactly as it should and returns {"isValid":bool,"value":"[email protected]"} but my message doesn't show up if isValid is false.
<span ng-show="userRegistrationForm.email_addr.$error.ngRemoteValidate">
This email address already exists.
</span>
And basically, this is what the email field looks like:
<div class="item item-input">
<span class="input-div">Email</span>
<input type="email"
name="email_addr"
ng-model="userAccountData.email"
ng-pattern="/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/"
ng-remote-validate="http://somewhere.com/api/check_email_existence"
ng-remote-throttle="400"
ng-remote-method="GET"
required>
<span ng-show="userRegistrationForm.email_addr.$error.ngRemoteValidate">
This email address already exists.
</span>
</div>
Maybe I don't know how to use formName.fieldName.$error.ngRemoteValidate
so maybe someone can tell me?
Also, I'm not sure about this but I decided to try and output value of formName.fieldName.$error.ngRemoteValidate doesn't work
like this:
<span ng-show="userRegistrationForm.email_addr.$error.ngRemoteValidate">
{{userRegistrationForm.email_addr.$error.ngRemoteValidate}}
This email address already exists.
</span>
...and using FireBug (in Firefox), it doesn't show any value.
I have form with two remotely validated input. They both have an ng-required condotion:
<form name="myName">
<input type="text" name="firstInput" ng-required="true"/>
<input type="text" name="secondInput" ng-required="false"/>
</form>
Now, if I add a remote validation to both the inputs, I observe a strange behaviour. If I get to a state where both the inputs are invalid (according to the remote validation), and I empty both of them, firtInput gets the ng-remote-valid class, while secondInput keeps the ng-remote-invalid class.
Now, even if I insert a value in the first input, my form stays invalid.
Hi there! Loving your plugin so far, but... do you think you could elaborate a bit more about the inputNameSetArgs callback?
E.g. What are the parameters? How do you name the callback? (Most of my form inputs have names like "licenseForm[name]". Symfony2 convention)
If I'm not mistaken, the server passes the success status of the validation (boolean) and a possible message to angular. I want to display those message, how can I access the variable?
Thanks for the useful plugin.
I would like to send through additional parameters (like an action) to the server. Is this supported?
First, thanks for the awesome module, it's a great help!
One problem I have though is the following:
It's easiest to check the issue with a long throttle, but it seems to happen without a throttle as well.
PS: There's a typo in the wiki at the very beginning "ngRemoveValidate".
Hi man! Thank a lot for this directive.
I have seen in code that var had called "dirictiveId"
But angular spelling is "directive"
It's confusing a little.
Hi,
I have a form with an email field that is added to a form with a ngIf condition and which is validated by my backend.
I have noticed that if I press enter (o submit with a button) before the validation has been processed, my form is submitted even if the email field has not yet been validated.
Is there any way to prevent the submission until all the remote validation are complete?
There should be a way to apply multiple remote validations to the same input field. As far as I can tell, you can only apply one.
An issue with this HTML: 'for' requires an ID to be set on the input field, e.g. <input id="currentPassword" ... >
Really nit-picky, just thought you might want to improve the HTML a bit.
<label for="currentPassword">Current</label> <input type="password" name="currentPassword" placeholder="Current password" ng-model="password.current" ng-remote-validate="/customer/validpassword" required>
The module is not currently being published to npm, could this be added?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.