hi,
am facing issue when writing validation of javascript functions within a content editor of my customnewform.aspx file of my SP 2010 SPList.
am having few textfields, number fields, dropdown choice fields for validation.
business rule #1:
When a dropdown item == 'ABC' , i need to have the below text boxes and number fields as mandatory fields else they are optional.
my js logic :
function PreSaveAction()
{
var dt3;
var dt4;
var dt5;
var dt6OralsDate;
var oralsdatethrusputility;
var dt7likelyStartDate;
var dt8dealResultDate;
var liklyStrtDatethrusputility;
var estimatedsizein;
var flagGeneric =true;
var opportunityidthrusputility;
//alert("inside presaveaction ..........");
opportunityidthrusputility = SPUtility.GetSPField('Opportunity ID').GetValue();
var opportunityTypethrusputility = SPUtility.GetSPField('Opportunity Type').GetValue();
//alert(opportunityTypethrusputility + '== is the opportunity type');
var valofestimatedsizeforEASORA = SPUtility.GetSPField('Estimated size (In KUSD)').GetValue();
var valDurationinMonths = SPUtility.GetSPField('Duration (in Months)').GetValue();
//alert(valDurationinMonths + ' == Oct 15 is the Duration in Months ');
if(opportunityTypethrusputility == 'ABC')
{
alert(valofestimatedsizeforEASORA + ' === Oct 15 within rfp if ...condition oct 15 for estimated size for Field' );
if(valofestimatedsizeforEASORA == null || valofestimatedsizeforEASORA.trim() =="")
{
flagGeneric = false;
alert('Estimated size for EAS ORC field is mandatory going 2 focus ');
alert(flagGeneric + ' ==is the flaggeneric value');
$("input[title='Estimated size (In KUSD)']").focus();
}
alert(' start the if condition for chking for duration in months field' );
alert(valDurationinMonths + '== is the duration value within condition ');
if(valDurationinMonths == null || valDurationinMonths.trim() =="")
{
flagGeneric = false;
alert('duration in months is mandatory on Oct 15 ');
}
}
alert(flagGeneric + ' == for overall flagg');
if(flagGeneric == false)
{
alert('please fill mandatory fields');
return false;
}
else
{
alert(' flagGeneric is true ');
}
here