Validate and show validation message one by one - validation

I have a page with 3 input fields with required attribute on each of them. If I click submit without entering any values in them, I get 3 messages on my page all at once. Is it possible to check for the fields in sequence and display messages accordingly?

Related

How to display combobox only under the lightning-input field which has a User Action?

I have a JSON which I have extracted. There is a field under the node 'NumberBlockDetails' under that, there is a field 'AreaCode' which is displayed as iterated. Currently based on the iteration, that field 'AreaCode' is displaying four times. It is based on one lightning-input condition only. But now as the user edits any one, the combobox is displayed under all 4 fields of Areacode. How can I display it only on 'Areafield' which has a user Action (like Onchange).
````<ul key={num}>
````<lightning-input type="text" label="AreaCode" value={userValue}> </lightning-input>
````<template if:true={flagValue}
````<lightning-combobox
````name=""
````options={}
````</lightning-combobox>
````</template>
````</ul>
````</template>
Currently for all 4 it is displaying when user clicks inside the field, how to show only under the field which is currently in action by the user for the same <lightning-input> field.
Can anyone suggest on this

p:messages with autoUpdate disappearsafter value change listener triggered

We have global p:messages defined in tempate with autoUpdate set to true.
This is the place where we are shwoing all the messages from included content.
On one of the pages we have panel with save button. User fill in some fields and after succesfull save we need to:
1. Display succes message
2. Fill in automaticly other fields on same page based on saved data
So in the bean we are adding FacesMessage , set data based on saved object and rerender those other fields.
Unfotunatly those fields have some value change listeners attachted to them. So we end up with two ajax requests. First from the save button and second from the value change listnerer defined on one of the auto filled fields. The result is that succes message appear for short amount of time (it dissapear after second ajax). How can we keep this message after second ajax without setting auto update on messages to false?
Thanks for any adivce.
P.S. We are using primefaces 3 so ignore autoUpdates is not an option :(

ASP.NET MVC 3: client-side validation message sticks around afterward if target field disabled

I have a form that has a field (Field A) that needs to be empty if Option 1 is selected on a dropdown, and is required if Option 2 is selected. I have some javascript that clears and disables the Field A when Option 1 is selected.
I have Simon Ince's RequiredIf attribute applied to Field A in the model, dependant on Option 1, and it works well. That's not the problem.
Here's the sequence of events that does cause a problem:
User has Option 2 selected (so that field A is required) and Field A empty.
User clicks on Save. Validation message appears by field A and in the validation summary. All is well.
User changes to Option 1. Field A becomes disabled.
User clicks on Save. Validation message remains by Field A but does not appear in the Validation Summary.
I conclude from this that the RequiredIf validation is working (and Field A is passing validation), but the old validation message is sticking around. Which I do not want.
All this is client-side, by the way.
If the field isn't disabled, everything works as expected, but I'd like it disabled rather than editable but "required to be empty".
Other than clear out the message SPAN tag through js and jQuery, is there a way to fix this?
Because the validation requirements are changing, you need to cause validation to occur, and then update all of the error messages. Since the issue relates to the change of the selected item on the dropdownlist, add the following:
$("#myDropDown").live("change", function() { // assumes dropdownlist has id of 'myDropDown'
$("form").validate().form(); // form() causes error messages to update
});

How to disable the display of validation errors in view (Cakephp)

I have a view which is containing 5 forms submitting separately but to the same model. The aim of this is allow the user to fill all the forms in the same page and be able to quickly compare the values he puts in for each form. Each form has most of the fields in common with another one. If you want a idea of the stuff, imagine that you are a soccer trainer and you want to be able on the same page to set up your team tactics for each half time. So I'll have a HalfTime model with two forms on the same page, one for each half time
So when I submit Halftime 1 form and that the validation fails, the validation errors of HalfTime1 is displayed in HalfTime2 fields too. I would like to be able to disable the validation of one form according if it wasn't submited.
My idea was to send a variable from the controller to the view containing the name/id of the current half time and from this variable, displaying validation errors only in the ccorrect form.
Do you have any idea on how I can disable the display of the validation errors in one field?
Thank you a lot!
Set the error option to false when you use form input. ie:
echo $this->input('Halftime2.title', array('error' => false));

Web Form with more than 100 fields

What would be the best design layout for a web form with more than 100 fields? Right now I have grouped the fields to tabs.I am having tough time in validating the fields.I should either validate it on 'Submit' of the form or on tab change.Both has its own drawbacks. If I validate on tab change then user cannot view other tabs till they fill all the mandatory fields in the previous tab.Also it is not an good idea to throw so many validation messages to the user when he submits the form.
Please share your thoughts..
You can use a stepwise process. In the first step provide all the most important fields. Then on the click of a 'Next' button you can go to the next step and so on. By validating the fields you can allow the user to go to the next step.

Resources