
Originally Posted by
dougeven
Hi,
I'm attempting to implement validation on a field in a Formview that ensures that the field is not empty or blank, i.e. it is required.
However the validation javascript never fires unless there is a value in the field. At least that's the behavior I'm seeing. If I put a simple "alert('fired');" in the "Validation Javascript" property the alert never appears until after I put some value in the field. It appears that if the value in the field is null or undefined the code in the validation javascript property is never called. If I'm right about this, I can't use this property to make a field "required."
How can I validate that a Formview field has a non-empty value?
Thanks.
Doug
Hi Doug!
Thank you for bringing this to our attention. Validation on the FormView control now occurs when you try to save the form back to the original data source.
If you have an existing FormView control with a Save button in the layout, you may need to either delete the Save button and add it again or modify the code for the click event for the button. Save buttons inserted into the FormView control layout will now contain this code:
Code:
var result = {dialog.object}.formViewValidate('{form.id}');
if(result){
{dialog.object}.formViewCommit('{form.id}');
{dialog.object}.formViewRefresh('{form.id}');
}
Check the click event for your save button in your existing FormViews to make sure the new validation checks have been added.
{dialog.object}.formViewValidate is a NEW function - it is available in Alpha Anywhere as of yesterday's build. I recommend installing the latest beta patch.
If you have defined validation rules for fields in your FormView, they will be checked when the FormView is saved - even if the data in the field was not modified.
In addition, there is a "Validate editor" event for Editors. You can add additional Validation code in this event.
Let me know if you have any questions!
Thanks!
Bookmarks