This can be accomplished using JavaScript.
Example: A Blocks file with two blocks ‘Phone’ and ‘Mobile’. At least one of them must not be empty.
Add the following code to Main layout (Bootstrap)
<script>
function _initPreview() {
if ($("[data-blockname='Phone']").val().trim()=="" & $("[data-blockname='Mobile']").val().trim()=="")
{
alert ("Phone and Mobile Cannot both be Empty!");
return false;
}
return true;
}
</script>
_initPreview is a special function that is called first when the Preview button is clicked. The above code gets the values entered for Phone and Mobile blocks and returns false if both are empty otherwise returns true. It is important to return a value for the preview process to stop or continue.
The block fields are selected using the data-blockname attribute, the value of which is the actual name of the block.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article