Wednesday 15 May 2013

Client side validation for rich text field in SharePoint 2010 using javascipt

Client side validation for rich text field in SharePoint 2010 using javascipt innertext property.



<script type="text/javascript">

var richtextboxid = document.getElementById('Your control id up to inplacerte');
if(richtextboxid.innerText.replace(/^\s+|\s+$/g,'')=="​" || richtextboxid .innerTextinnerText.replace(/^\s+|\s+$/g,'')=="")
// Sometimes empty rich text box contains a square box so  check for that box also
// Copy above code in notepad you will find that sqare box or you can find form IE developer tool

{
alert("Please enter Rich text value");
return false;

}
 </script>