Set field as required on portal form based on option from dropdown

Forum Post: Change the Filter On option on Opportunity Associated View for Account form

I am using the below code to show/hide a field based on a selection in a dropdown box.  The show/hide feature is working correctly but I want to make the field that is shown mandatory but .attr(‘required’, true); does not appear to be working. 

How can I achieve making input into this field mandatory? 

// Make vet reg required if the occupation is PVP

$(document).ready(function() {


function SetVetRegRequired() {
var selectedValue = $("#ahi_occupation").val();

if (selectedValue == "100000002")
    $("#ahi_vetreg").show().attr('required', true);

Source link

Leave a reply

Please enter your comment!
Please enter your name here