In my scenario I want to disable a save form button if the form has not been touched. I'm currently using v-slot="{ untouched }" on the validation-observer to achieve this. One of my checkboxes, however, is not wrapped in a validation provider. I.e., it's optional/not required. The problem is that whenever the checkbox value changes, my validation observer still has untouched set to true (assuming that's the only thing I've changed in the form). So I can't save my form even though I made a change to a boolean value. Is there a way where I can set my validation observer to istouched = true when my checkbox is changed? Or perhaps I need to manually check controls that have been changed that are not wrapped in a validation-provider tag.
FYI I'm using vee-validate 3.0
Related
I have a simple unbound access 2016 form. On the form, I have several controls including text and combo boxes. On the first text box control I would like to require a data value (underlying table field data type is short text).
I have set the Validation Rule property for the control in the property sheet to "Is Not Null" and added an appropriate validation text message.
For an unknown reason I have not been able to get this validation rule to ever fire. I have cleared the validation rule on the table to make sure it wasn't interfering, however, no luck.
It's like the validation check is not happening when focus leaves the control. There is no other event procedure that has been written that would interfere either.
Thanks for the help.
You can give the control a default value, then
Form_load()
Yourcontrol.setfocus
Sendkeys "{DEL}"
The requirement was to validate the control for a missing value using the validation rule when the control lost focus (ie user tabbed out of text box without ever entering a value). I wanted the user to get immediate feedback that they needed to provide a value for the given control.
As Rene pointed out in the comments, the validation rule does not fire unless there has been a value change.
The Sendkeys solution has issues, I only use Sendkeys as a last resort.
The solution in this case was to put the validation test in the Control_OnExit event handler. The user gets immediate feedback as desired and does not wait until the record is submitted.
One further note that could easily be missed; in an unbound form, the before_update event will never fire.
As expressed in this backbone.validation issue, when using the plugin as shown in this fiddle, we should get a validation performed by isValid() - without params.
If the this.model.attributes have changes, isValid() should validate the properties on this.model.attributes however that's not the case in the example.
What I'm aiming for is to constantly, when there's a change to a the model/form, re-evaluate the validity of the entire form, and based on the outcome enable or disable the submit button (in the fiddle example though, the validation will only happen when clicking the submit button).
I do not want to use isValid(true) because then all fields that have yet not been filled in will get validated by force.
The desired behavior is to validate the dirty fields, but also recognize that the clean fields aren't valid yet (thus not enabling submit button) - but clean fields shouldn't be validated visibly to disturb the user with errors, just under the hood, to enhance the behavior of the submit button.
Am I approaching this problem the wrong way with backbone.validation?
I have a wicket page with a couple of TextFields that have different kind of validators. So far, validation is triggered via Ajax on the onChange event.
I also have a checkbox that defines which set of validation rules should be used for the TextFields.
If I click the checkbox and then input data into the TextFields, validation works just fine. But how do I handle the fact that already entered and validated data can suddenly become invalid if the checkbox is clicked afterwards? How do I trigger the validation and the redraw (to show the error notification) of the TextFields from within an AjaxEvent from the checkbox?
I tried to call myTextField.validate() but that didn't trigger any of my validators.
Since your validation is based on multiple components you should implement IFormValidator. Pass both checkbox and textfield in getDependentFormComponents() and change of either will trigger it.
Also if you are using checkbox to refresh some elements make sure to use AjaxCheckbox, that has onUpdate(AjaxRequestTarget) method.
You could attach an AjaxFormSubmitBehavior in the checkbox. This would submit the form and trigger validation each time the checkbox value is toggled.
I have a text box and value change listener on it. And there is a save button. The user avoids/bypasses value change listener by directly editing text box value in html code and then saves it. How can i prohibit the user, so that he/she is not able to change value this way? And thus make sure that value change listener is always called.
I am looking for some generic mechanism to stop such cases on all inputs/and event listeners.
Thanks
You need to accept that the user can actually do EVERYTHING he wants with his client (the browser). He can disable Javascript, remove inputs completely, change validation or call Ajax functionality manually. He might not even use a browser and send an HTTP request using a command line tool.
It is just impossible to prohibit such things.
On the other hand I think that in case you use a valueChangeListener on your h:inputText, then it should be called in any case, because it will be evaluated serverside. It might be that you edited it the wrong way and the value actually doesn't change when you save the content of the form. (Check that the value really gets set by adding a breakpoint to your setter).
If you use Ajax functionality using <f:ajax> with event="change" and a listener, then there is no way to prevent bypassing it by manually editing the html. Either check for the changed value in your save method, or use the valueChangeListener instead.
I just finished my first CRM callout, and it's working great, but it doesn't actually seem to take effect until the form that calls it is saved. It's a PreCreate deal that assigns a value to one of the attributes present on the form. Is there any way to get it to assign the new value and display it on the form as soon as you load it, or is this just the way it works?
You'd have to add some JavaScript to the onload event of the form and default any form fields that way. Callouts don't fire until after the save event happens, so they can't be used to default fields in the UI.