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.

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

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

| improve this answer | |
  • Let me try and revert.thanks for your time -@ Nagarajan. – userAZLogicApps Oct 28 '15 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. – userAZLogicApps Oct 29 '15 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 " – userAZLogicApps Oct 29 '15 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 --------------------------- – userAZLogicApps Oct 29 '15 at 10:44
  • instead of detailedStatusTxtValue == null use detailedStatusTxtValue == "" and check it. – Nagarajan Muthukumar Oct 29 '15 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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