A user selects text and it replaces with 'a' tag id='NewLink', when he'll has finished with description for a word or phrases the server will get innerHTML of content div 'StartId'. I need to overlook that a user doesn't change the html code on a client side in browser. How I can do it?
  function GetSelectedText () {
   var sel = window.getSelection();  
            
   if( sel.toString().length != 0 && sel.getRangeAt) {
   $('#NewLink').replaceWith($('#NewLink').html());
     var rng, se, err, errt, patt;
     errt = 0;
     try {
    
     se=$('<span style="background-color: #3366CC;" id="NewLink">')[0];
        rng=sel.getRangeAt(sel.rangeCount-1);
        rng.surroundContents(se);
        rng.selectNode(document.getElementById("NewLink"));
         } catch (err) { errt = 1;}
    
        if(errt != 1)  
        {
        patt=new RegExp("</?a.*?>","g");
        if (patt.test($("#NewLink").html()) ||$("#NewLink").closest("a").length||!$("#NewLink").text().replace(/\s/g,"").length) 
        {$("#NewLink").replaceWith($("#NewLink").html()); }
        else { rng.collapse(!0);}
        }
    }
    var StartId = document.getElementById("StartId").innerHTML;
    $.post('site.com', {htmlInner:StartId}, function(data) {
    alert(data);
    });
      
    } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="StartId" onmouseup="GetSelectedText ()">
Carnotaurus, a large theropod dinosaur, lived during the Late Cretaceous period. Known from a single well-preserved skeleton found in Argentina, it is a member of the Abelisauridae family<a href="#">and one of the best-understood theropods from the Southern Hemisphere. <br>Carnotaurus (derived from Latin for "meat-eating bull") <br> had thick horns above the eyes, and a very deep skull on a muscular neck.</a> <br>It was a lightly built, bipedal predator, 8 to 9 m (26.2 to 29.5 ft) long, weighing at least 1.35 metric tons (1.49 short tons). It had small, vestigial forelimbs and long and slender hindlimbs. Preserved skin impressions show a mosaic of small scales interrupted by large bumps that lined the sides of the animal. </div>
<div id="EndId"></div> 
    