Hello Community!
I am working in SP 2013 and I am developing a validation for a SharePoint form (adding the JavaScript using a CWP).
The form has two fields - "System Availability Impact", a Boolean field, and "System Availability Impact Reason", a Rich Text field.
The JQuery validation ensures that if the "System Availability Impact" field is checked, then the "System Availability Impact Reason" contains text.
Here's what works within the code:
- If the user checks the "System Availability Impact" field, but does not add text to the "System Availability Impact Reason", the code throws an error message and will not save the form.
- If the user checks the "System Availability Impact" field, and adds text to the "System Availability Impact Reason", the code will not throw an error message and instead it will save the form.
- If the user checks the "System Availability Impact" field, but does not add text to the "System Availability Impact Reason", the code throws an error message and will not save the form, but then, if the user goes back and adds the "System Availability Impact Reason" and tabs out of the "System Availability Impact Reason" and then clicks the save button, the form saves
Here's what does not work in the code:
- If the user checks the "System Availability Impact" field, but does not add text to the "System Availability Impact Reason", the code throws an error message and will not save the form, but then, if the user goes back and adds the "System Availability Impact Reason" but does not tab out of the "System Availability Impact Reason", and then clicks the save button, the form will throw and error as if the text was not added and the form will not save
Has anyone else seen this issue? If so, then please provide guidance and coed examples.
Thanks!
Tom
// Validate System Availability Impact //
function checkSAI(){
var content = $("textarea[Title='System Availability Impact Reason']").val();
content = content.replace("</div>","");
content = content.replace(" ","");
content = content.replace(" ","");
content = content.replace("<div>","");
alert("SAI Content ' " + content);
//$("textarea[Title='System Availability Impact Reason']").val(checkContent());
if($("input#ctl00_ctl40_g_0238d60e_b989_47d7_9928_bec0740f535b_ff201_ctl00_ctl00_BooleanField").is(':checked'))//System Availability Impact
{
if(content == "")
{
alert("Please Add the System Availability Impact Statement");
return false;
} else {
alert("Content Provided");
return true;
}
} else {
return true;
}
}Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award - Linked-In - SharePoint Gypsy