I have a small request. I am validating few fields in pre save function through j query. The problem that i am stuck on is that, i have a drop down named = "Is the Process flow document available?" and "Frequency of deliverable" which are visible only when the single line text field "Nature of work" contains "Execute Business processes or Deliver periodic reports". Now i am able to check there validation when the "Nature of field contains" the above two mentioned values but when the text field does not contain any of the value these two fields are hidden in the form , but when the validation runs it checks for the hidden fields too. I want to perform validation only when the fields are visible in the form.
Here is my code for hiding the fields when single line text field not equal to the values specified above
var txt = $("input[title='Nature of the work']").val();
if ((txt != "Execute Business processes") && (txt != "Deliver periodic reports"))
{
$('nobr:contains("Is the Process flow document available")').closest('tr').hide();
$('nobr:contains("Frequency of the Deliverables")').closest('tr').hide();
}
else
{
$('nobr:contains("Is the Process flow document available")').closest('tr').show();
$('nobr:contains("Frequency of the Deliverables")').closest('tr').show();
}
Here is my code for validtaion
fucntion PreSaveAction(){
point of contact = $("select[title='Is the Process flow document available']").text();
Frequencydeliverables = $("select[title='Frequency of the Deliverables']").text();
if(point of contact=="Select a Value")
{
alert("Please select an appropriate value");
$("select[title='Is the Process flow document available']").focus();
return false;
}
if(Frequencydeliverables=="Select a Value")
{
alert("Please select an appropriate value");
$("select[title='Frequency of the Deliverables']").focus();
return false;
}
return true;
}
If you guys can help me out please do thank you !