In Umbraco, I have a document which is having 3 properties. Out of 3 two of them are mandatory, so i checked the mandatory checkbox in property tab. When i click save and publish the document is published without showing any validation errors.
But for the last property, I am looking to create a custom validation as here I need to check whether that property is having value in it, if it has then validation should fail. I cannot use mandatory checkbox as this checks for value presence.
I actually haven't figured that one out. Yet in v4 it was possible to set the speechbublle...But since v6 and the introduction of the new API I haven't got it to work (yet).
Custom validation in umbraco
In Umbraco, I have a document which is having 3 properties. Out of 3 two of them are mandatory, so i checked the mandatory checkbox in property tab. When i click save and publish the document is published without showing any validation errors.
But for the last property, I am looking to create a custom validation as here I need to check whether that property is having value in it, if it has then validation should fail. I cannot use mandatory checkbox as this checks for value presence.
Any suggestions?
Hi Hash,
Just out of interest: why would you want a field to be empty at all times in Umbraco? :-)
- Bo
I am also looking something similar.
I have propery call "umbracoUrlName".
On click of save and publish I would like to check the uniqueness of its value for Url Name on same document type.
If the "umbracoUrlName" is unique it will save and publish.
If not then It will display some custome message in umbraco back office.
Is it possible to achieve and how?
Or any better way to do it.
Thanks
-Keyur
You can hook in on the saving event of your document and do your validation there. When the validation fails you can cancel the saving.
More information on hooking in to the contentservice events can be found here : http://our.umbraco.org/documentation/Reference/Events-v6/
Dave
Hi Dave,
Thanks for quick response I will try it and let you know and can we set custom message over there to show it in back office ?
Thanks,
Hi Dave,
I have achieved the way you suggested but struggling to show speech bubble(custome message).
Thanks,
I actually haven't figured that one out. Yet in v4 it was possible to set the speechbublle...But since v6 and the introduction of the new API I haven't got it to work (yet).
Dave
is working on a reply...