In one of our projects we want to show the "Required field validation error" by changing the border color of the corresponding textbox. our page contains a lot of required field validator,regular expression validator etc. But we want to highlight only the required field errors.
Is there any way to do this without using any custom validation function.?
or Is there any method to find all the required field validators in a page in the client side. If we can find this i think we can highlight the corresponding error textbox
one option, maybe less annoying than switching to custom validators, is to create your own javascript validation function that is triggered with a submit click. from here you can change the appearance of the invalid fields.
Related
I am using Ninja form and I have a checkbox field. On click of this checkbox I have two input fields which are displayed. I have to make both the fields as required. How can I make both of them required?
I've used jQuery to add required property but when I click on submit the form is submitted without showing any errors.
I
Know a Employee
Employee Full name
Employee Email
I used the conditional logic extension for showing and hiding the two input fields on checking and unchecking of the Checkbox. Also, Used jQuery for acheiving the same functionality. Expected output, On checking the checkbox, Both the fields should be visible and required before submitting the form
Scrap the extra jQuery, just simply make the fields required using the
provided toggle option
Then setup the conditional logic so that the fields are hidden when they're not checked and vice versa. When the fields are hidden it will act as if they don't exist, meaning you will not be required to fill out the hidden required fields to submit. But when the box is checked and they show again you will have to fill out the fields. If this doesn't work try updating your conditional logic add-on, as I don't think it always worked like this.
I have a text box control that I'm wishing to apply custom field validation to. The data I'm validating in the text box is used as a primary key in the database I've set up. I need custom validation controls that allow me to check for duplicates before the data is submitted.
I would like the user to be prompted to enter different input if the validation returns that the data exists.
you better add OnTextChange property to textbox and perform the primary key validation in that function.
My problem is this: I need to have a way to repeat a custom textbox control with validators and have each validator fire for each control uniquely (as opposed to one text box failing validation and the validators fire for all other controls also using that validator).
My idea was maybe to set the control to validate property uniquely for the full client ID of each?
I've associated a custom javascript function to the text box blur. It uses jquery to nab the validator controls nearest to the sender (and only those nearest). I loop through them and call ValidatorValidate.
In addition to my above problem, this also allows me to only show the validation error that makes sense at the time (i.e. on blur of text box i don't want to show required field immediately because it's truly not required till i take action elsewhere... so I determine this by the sender and hook into this method in other locations).
I also don't show multiple. If its beyond my range specified, i only show that (as opposed to other custom validators i have that would otherwise fire).
I am using an ajax tab control. I am using a combination of required field validators and custom validators. I am using a validation summary at the end of the page. My problem is when there is a validation error on different tabs I get an IE error because it cannot set focus on all of the fields at once because they are on different tabs. I know if I set focus on error to false the error does not occur. Is there any other way around this?
Set the ValidationGroup of groups.. for more info click
I have a form with two text boxes. Once I enter the data and click the save button, I get a message in label: indicating that it saved successfully.
Then I show the form again, but when I click on the save button, I get a message telling me that it cannot be blank "as textbox value is empty this time" from the required field validator.
But I am still showing the message "data saved successfully," which should not happen.
How do I solve this issue?
Thank you.
You need to set ValidationGroup on your textboxes, requiredfieldvalidators, and buttons to the same value. This will prevent (theoretically) the saving of blank values when the validators fire.
HOWEVER, do server-side validation too! The above is easy to sidestep.
Off the the top of my head, my suggestion would be to add an "OnClientClick" event your save button that calls out to a script which hides the "success" message client-side. I'm not sure if there is a way to trigger client-side code when client-side validation fails - without using a CustomValidator, but I could be wrong.