Q. Is it possible to have two fields in blocks but one of the blocks is mandatory to fill out?
A. Yes using javascript in the boostrap layout section for the product you can enter the following. substiture phone and mobile for block names.
<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>
For Multipart blocks use something like this:
<script>
function _initPreview() {
if ($("[data-blockname='Direct'] input").val().trim()=="" & $("[data-blockname='Office'] input").val().trim()=="")
{
alert ("Direct and Office Cannot both be Empty!");
return false;
}
return true;
}
</script>
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