1

How to validate Enhanced Rich Text Field on PreSaveAction call in my SP 2010 list form's newform.aspx. I tried with JavaScript but it didn't work.

I followed Marc's blog here

But the issue is, once it's validated successfully, I delete the text contents again and re-enter the text contents again and tried to validate and it failed! Also the field needs to be mandatory field.

2
  • How did you retrieve the rich text content in PreSaveAction? Commented Oct 28, 2015 at 9:26
  • $("textarea[Title='Detailed Status']").closest("span").find("iframe[Title='Rich Text Editor']").blur(function(){ alert($(this).contents().find("body").html()); });
    – samolpp2
    Commented Oct 28, 2015 at 9:28

1 Answer 1

2

Try using this code

$("td.ms-formlabel h3.ms-standardheader nobr:contains('Field Name')").parent().parent().parent().find("div.ms-inputBox div.ms-rtestate-write").text()

Replace the 'Field Name' token with column display name

6
  • Let me try and revert.thanks for your time -@ Nagarajan.
    – samolpp2
    Commented Oct 28, 2015 at 11:18
  • the above didn't work for me, when I edit the form,though the old status text values been mentioned already and it didn't fetch the latest value, it seems.When I tried to alert the status value am not getting any value. but its not null text.
    – samolpp2
    Commented Oct 29, 2015 at 10:41
  • var detailedStatusTxtValue = $("td.ms-formlabel h3.ms-standardheader nobr:contains('detailed Status')").parent().parent().parent().find("div.ms-inputBox div.ms-rtestate-write").text(); alert(detailedStatusTxtValue + ' is the current detailed status value '); if(detailedStatusTxtValue == null ) { alert('detailedStatusTxtValue Value is mandatory!'); return false; } else { alert('detailedStatusTxtValue is not null'); //return true; } and as the result, i got the message "is the current detailed status" value "
    – samolpp2
    Commented Oct 29, 2015 at 10:43
  • instead of entering in the if loop, it enters inside the not null block and get the result as --------------------------- Message from webpage --------------------------- detailedStatusTxtValue is not null --------------------------- OK ---------------------------
    – samolpp2
    Commented Oct 29, 2015 at 10:44
  • instead of detailedStatusTxtValue == null use detailedStatusTxtValue == "" and check it. Commented Oct 29, 2015 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.