function wordCount()
{
    var noWords;
    noWords = 0;
    
    var c1 = 0;
    var t1;
 
    var htmlString = document.getElementById("textwords").value; 
    
    if ( document.getElementById("textwords").value.length > 0 ){  
        if ( document.getElementById("checkwords").checked ){ 
            htmlString = htmlString.replace(/(<([^>]+)>)/ig,""); 
 
            t1=htmlString.replace(/\s/g,' ');
            t1=t1.split(' ');
            for (z=0; z<t1.length; z++) {if (t1[z].length > 0) c1++;}
            noWords=c1;  }
        else {
        t1=htmlString.replace(/\s/g,' ');
        t1=t1.split(' ');
        for (z=0; z<t1.length; z++) {if (t1[z].length > 0) c1++;}
        noWords=c1;  } }

    document.getElementById("noofwords").value = noWords;
}

function characterCount()
{
    var noChars=0;
    var txtChars = document.getElementById("textchars");
   var c1 = 0;
    var t1;
    
    if ( txtChars.value.length > 0 ) {
        
        var y=txtChars.value;
        var r = 0;
        var a;
 
        if ( document.getElementById("checkchars").checked ) {
             noChars=txtChars.value.length; } 
        else {  
                var x ;
                x = txtChars.value.replace(/\n/g,'');
                var y  = x.split(' '); 
                
                noChars = x.length - ( y.length  - 1) ; 
            }
        } 
    
    document.getElementById("noofchars").value = noChars;
} 

function txtClear1()
{
 
   
    document.getElementById("textchars").value=""; document.getElementById("textchars").focus();
}

function txtClear2()
{ 
     document.getElementById("textwords").value="";document.getElementById("textwords").focus();
}