Most effective way to make jquery field validation - javascript

what is the most effective way to make a jquery field validation? For example if field name is empty, it will add empty checkmark next to field? I understand, that PHP validation is needed, and I have it, so no worries about that.

You can try JQuery inline validation.
From here you can try out many examples
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

Related

How does one set custom validation on an Angular form?

I am trying to set custom validation on an input field in an Angular app. The validation cannot be set to a pattern, since it is based on the content of another field (e.i. Passwords must match)
A way to do validation in this case is to check for the fields on form input. However, I want to be able to check for the validity in real time, and be able to use CSS classes such as .ng-dirty and .ng-valid, which come when Angular takes care of validation.
I tried to use $scope.formName.inputName.$setValidity(...), but I am running into issues on that end (StackOverflow question here).
Is there another way in AngularJS to set custom validation?
As mentioned if you check
https://docs.angularjs.org/guide/forms#custom-validation
You'll see you can use directives to create your own custom validations, in the example provided the validation is done whenever you input a character.
If you use your browser to inspect the example (username input field) you'll see the classes (ng-not-empty ng-dirty ng-valid-parse ng-touched ng-valid ng-valid-username) being changed on the fly.
If you had a form these classes would be taken into account to change the form.$valid property to true or false. By default if form.$valid is false then you can't submit it.
I know this doesnt answer to your question but I found a couple of directives that can do that for you:
https://blog.brunoscopelliti.com/angularjs-directive-to-check-that-passwords-match/
https://github.com/TheSharpieOne/angular-validation-match
Try it out to see if its what you need.

jQuery Validate plugin with styled radio and checkboxes

Here is my problem, I'm using jQuery validate to validate a form.
Problem is,I have special styling for my select boxes, I use the bootstrap select.
Now, this basicly re-generates an UL with a LI dropdown.
Is there a way with jquery validator too make sure one of these are selected, and to refuse the form if the first one is selected.
Anyone have any experience with what I wish to do ?
Thanks in advance !
Bootstrap select seems to be using the UL/LI combination to display something nice to the user but is still changing the value of the hidden select box for when it is posted.
What you will need to do is to modify the ignore handler in jQuery Validate, this is set to ignore all hidden fields by default.
I have had to deal with the same problem and written a custom invalid handler that allows you to write exceptions for fields hidden for this reason.
Check out the Validation Docs and find the bit about ignore handlers.

AngularJS validating outside of a form

I have a more or less complex SPA with ~40 text input fields. Those input elements are not bundled by a <form>, but they are separated into categories. If a user submits, i would like to trigger a validation function.
My first approach was writing two directives, one for string input and one for numeric values, which would add an attribute to every invalid element, then using a validate() function which would look up every input field in order to check whether or not it has said attribute.
I stumbled over multiple issues, including the fact that this was a jQuery like solution to the problem.
How could i accomplish this in a more convenient way?
One of the ways I have been handling form validation when things are not inside of a form is by using ng-pattern. With ng-pattern you can either do direct regex there, or link to an expression to run a set of validations for you.
It would look something like this.
<input type="text" ng-pattern="Put your Regex Here or an Expression">
The angular docs for ng-pattern are pretty sparse, so good luck.
This approach may not be what you are looking for since it evaluates only one input at a time, but I hope this helps.

Input validaton with a function call jquery

I am trying to find the correct jquery plugin to validate a few input elements on my page. I would like to be able to have the validation happen on the fly and if any of the validations fail it will call a function. I have been researching this and I can not find a good example on how to do this or what plugin to use. I ultimately just want to validate a few input fields such as first name, last name, email, phone, etc. and if any of them fail the Submit button is disabled. Any ideas?
Try this one -- looks like it does what you want.
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Ideas on limit the text on textfield?

for example, I want the textfield input number only. my idea is when the user typing, it will call a javascript to check whether it is valid, if it is not valid, I delete the text which is just entered. But I think it is very complex to do so. Is there any simple way to do so?
Put a validation on submit.
JQuery Masking could be a good choice: http://digitalbush.com/projects/masked-input-plugin/
The script to do this is here. It's a pretty common requirement.
http://javascript.internet.com/forms/validate-numeric-only.html
I think, like o.k.w said, jQuery Masking would be a good choice because of 2 things:
jQuery is solid and fast
Masking is more user friendly than just deleting user input on the fly without any notification. Masking gives them a graphical reference of what type of input is expected and what the input might look like.

Categories

Resources