How to Count String Words Using JavaScript?

Hello friends, today I will tell you through this tutorial how you can count any string word by javascript. I will tell you step by step through this tutorial.

Count Words Using JavaScript or Jquery, Count Words with JavaScript, Count Words in String Using JavaScript, How to Count Words by JavaScript or Jquery?

<!DOCTYPE html>
<html>
<head>
<title>How to Count Words Using JavaScript?</title>
</head>
<body>
<h1>Count Words Using JavaScript</h1>
<form>
<textarea name="stringvalue" id="stringvalue" cols="50" rows="4">How to Count Words Using JavaScript?</textarea>
<br>
<input type="button" name="Convert" value="Count Words" onclick="countstringWords();"> 
<input name="wordcount" id="wordcount" type="text" value="">
</form>
<script>
function countstringWords(){
svalue = document.getElementById("stringvalue").value;
svalue = svalue.replace(/(^\s*)|(\s*$)/gi,"");
svalue = svalue.replace(/[ ]{2,}/gi," ");
svalue = svalue.replace(/\n /,"\n");
document.getElementById("wordcount").value = svalue.split(' ').length;
}
</script>
</body>
</html>
Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.