If the fields are required (in list settings) then you have to pass some value to those fields. you cannot leave them blank even if those are hidden fields.
So, do not make the fields required from list settings.
If you need some fields to be required only if the specific choice is selected from dropdown then you have to customize the list forms using JavaScript/JQuery.
For Example:
Consider, you have a choice field with its display name as Information Type
and one date field (named Review Date
).
And you want to make Review Date
as required field only if the "Client Lost" or "Client Retained" option is selected from Information Type
dropdown.
Then you can use PreSaveAction()
like below:
function PreSaveAction() {
var returnValue = true;
returnValue = returnValue && ValidateReviewDate();
return returnValue;
}
function ValidateReviewDate() {
var ddlInformationType = $("select[title^='Information Type']")[0];
var txtReviewDate = $(":input[title^='Review Date']")[0];
if(ddlInformationType[ddlInformationType.selectedIndex].value=="Client Lost" || ddlInformationType[ddlInformationType.selectedIndex].value=="Client Retained" ) {
if(txtReviewDate.value.length == 0) {
alert("Please enter Review Date");
txtReviewDate.focus();
return false;
}
else {
return true;
}
}
else {
return true;
}
}
Note: Make sure you have added reference to JQuery file before using above code as it using JQuery ($) selectors to access the fields on form.