Hi,
I have a status column(drop-down) in my form and a Assigned To(people picker).
I need to have a condition, if the value of status = Transferred, then, Assigned To should be mandatory.
Here is the code that I have implemented:
<script language="javascript" type="text/javascript">
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" ||
tempString.indexOf(identifier) == tempString.length - len)) {
return tags[i];
}}
return null;
}
function PreSaveAction() {
var theInputDDLTS = getTagFromIdentifierAndTitle("select","DropDownChoice","Status");
var theInputMLTRR = getTagFromIdentifierAndTitle("Textarea","UserField_downlevelTextBox","People Picker");
if(theInputDDLTS.value == "Transferred")
{
if((theInputMLTRR.value == "") || (theInputMLTRR.value.charCodeAt(0) == 32))
{
alert("Please fill Assigned To, if task is transferred");
return false;
}
}
else
{
return true;
}
return true;
}
</script>
But this is not working, it does not give me any alert box or validation and simply saves the task.
Regards, Priyanka Makkar