ADF Client side validation – Email validation:
I want to add a validation rule to an email field so it doesnt accept invalid emails when entered (but remains not required, so its either empty or valid).
I used a Validate Regular Expression on the Email field in the jsf page with these arguments:
Pattern: ^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)#[A-Za-z0-9]+(\.[A-Za-z0-9]+)(\.[A-Za-z]{2,})$
Message: You have entered an invalid email address. Please try again.
The problems are:
1- When entering an invalid email, it works but when entering a valid email the error message still appears.
2- The email field becomes mandatory even though its not.
Related
I need to make validation rules like this:
Create a validation rule that displays an error message and prevents the user from creating or updating a contact if both conditions are true.
Create a validation rule:
Rule name: Contact_must_be_in_Account_ZIP_Code
Operator: AND (returns true if both conditions are true)
Define two error conditions:
The contact is associated with an account ID
Hint: use the ISBLANK and NOT functions.
The zip code for the contact's address is different than the zip code for account submissions.
Tip: Use the API names (MailingPostalCode and ShippingPostalCode) and the <> operator (Not equal to).
Enter an error message for the validation rule
?
I'm in training and I've tried everything to solve it but nothing worked
I have a signup form where the user is supposed to enter amongst other personal details also his phone number's country prefix (e.g. '+49' for Germany). Now I have a script running which automatically detects the country prefix according to the user's IP geo location.
If the IP location is successfully determining the user's current location, it puts the country code automatically in the signup form's prefix field.
This means that the user doesn't have to enter the prefix manually.
My question is: once the signup form is loading, and all fields are empty except for the country prefix, how can I validate the country prefix field successfully prior to hitting the submit button?
I tried all kinds of triggers from the jQuery Events page as suggested by the ParsleyJS documentation but I don't get it done..
Any help on this would be gladly appreciated!
Edit to further clarify: If you're visiting the signup page, the IP location script detects your location, translates that into your country's phone prefix, and puts that number into the "Prefix" form field. So you don't have to put there anymore by yourself. This works only if the the IP locations script successfully identifies your location of course, however this works in most of the cases. So what I would like to achieve is that this form gets it's green validated background, although you didn't put in the prefix yourself. In other words, the prefix is already in the field in most of the cases.
I'm using the data-parsley-triggers, no jQuery or JS to validate the whole form.
You can see in the picture that I entered a first name, Foo, which validated upon data-parsley-trigger="change". The blue arrows show the fields which have been filled automatically by the IP location - and they are not validated as I'm missing the right trigger.
It's not clear what you are trying to achieve (why validate the field when it's clear it will be valid), but why not simple $('input[name="phone_prefix"]').parsley().validate()?
I'm using the Angular framework with Angular Material controls in my recent application. I'm looking for a good solution for the following problem:
A form form with an input field named nickname is shown to the user. After the user has chosen a nickname and submitted the form, the server checks whether the nickname has already been taken. In that case, it returns an error to the Angular client.
To show an appropriate error to the user, the code then calls form.nickname.$setValidity('nicknameTaken', true). The new ngMessages module is used to display the error to the user. Further form.$isInvalid is used to disable the form controls to prevent the user from resubmitting the invalid nickname.
My problem is now the following: I'd like to have the error nicknameTaken automatically being removed as soon as the user begins to edit the form fields again. What is a good way to do this? Is there a predefined route to go when it comes to server-side validation errors of this kind? (Note that I am not asking for asynchronous validation because I only want to contact my server when the form is actually being submitted.)
I would write a normal validator directive instead. Something like
<input blacklist="takenNickNames" .../>
This directive would simply add a validator to the input, and this validator would make the input invalid if the model value is contained inside the given takenNickNames array (and valid if it's not present).
The takenNickNames array would be empty initially. When the form is submitted and the error comes back, the controller would add the invalid nick name to the array.
So, every time the user would enter something, the validator would be triggered, and would set the field valid or not, based on the taken nicknames stored in the array.
Here is a working example.
I am trying to use AngularJs Valdr plugin, but I realized that when adding + sign to email address, the validation passes.
What I mean is, I have an input with name email, and valdr-type is email.
When I enter something like, email#example.com, it passes (which is OK), but changing to +email#example.com also passes the validation.
Same for an email without domain extension (eg. email#example)
Any idea please ?
Thank you !
Per Valdr documentation:
https://github.com/netceteragroup/valdr#email
email
Checks that the field contains a valid e-mail address. It uses the same regular expression as AngularJS is using for e-mail validation.
Per angularjs documentation:
https://docs.angularjs.org/api/ng/input/input%5Bemail%5D
"Note: input[email] uses a regex to validate email addresses that is derived from the regex used in Chromium. If you need stricter validation (e.g. requiring a top-level domain), you can use ng-pattern or modify the built-in validators (see the Forms guide) "
In my form I have a username field that is user for registration. I would like to make this trigger an error message on the field. Something like the error message I would get if I did not enter a value on a field with ng-required.
Can someone tell me how I can make it so that when a user leaves the field then an HTTP request is sent to the database to check for an existing username and then if present an error condition is set for that field.
I am not really looking for specific HTTP request code but just even some pointers would be a big help.
Here's a nice guide on how to check a name field using custom directive and new features from 1.3