0

I have a drop down where if I select "Yes", two other form fields that are hidden via hidecolumn, will then show via showcolumn event. The drop down is a required field and so are the other two form fields. The issue I am having is that, if I select "No" on the drop down and try to save, nothing happens. I am guessing is the hidden form elements which is required is preventing the form to be submitted. Is there a keyword I can use in the showcolumn to appear as required without going to through the list setting route? JS? JQuery? Here is my code:

// Function to hide a column's row in the form
function hideColumn(c) {
  $(".ms-formlabel h3 nobr").filter(function() {
    var thisText = $.trim($(this).clone().children().remove().end().text());
 //   alert("::" + thisText + "::");
    return thisText.indexOf(c) === 0 && thisText.length === c.length;
  }).closest("tr").hide();
}

$(document).ready(function() {

// Function to hide a column's row in the form
function showColumn(c) {
  $(".ms-formlabel h3 nobr").filter(function() {
    var thisText = $.trim($(this).clone().children().remove().end().text());
 //   alert("::" + thisText + "::");
    return thisText.indexOf(c) === 0 && thisText.length === c.length;
  }).closest("tr").show();
}

$("select[title='Question One? Required Field']").change(function(){
  if($("select[title='Question One? Required Field']").val() == "Yes"){
    showColumn("Question One-One?");
    showColumn("Question One-Two?");
  }else{
    hideColumn("Question One-Two?");
    hideColumn("Question One-Two?");
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.