HTML CODE
<div id="border"> <textarea id='text'></textarea> </div> <button id="count">Count</button> <div id="result"> Words: <span id="wordCount">0</span><br/> Total Characters(including trails): <span id="totalChars">0</span><br/> Characters (excluding trails): <span id="charCount">0</span><br/> Characters (excluding all spaces): <span id="charCountNoSpace">0</span> </div>
JAVASCRIPT CODE
counter = function() {
var value = $('#text').val();
if (value.length == 0) {
$('#wordCount').html(0);
$('#totalChars').html(0);
$('#charCount').html(0);
$('#charCountNoSpace').html(0);
return;
}
var regex = /\s+/gi;
var wordCount = value.trim().replace(regex, ' ').split(' ').length;
var totalChars = value.length;
var charCount = value.trim().length;
var charCountNoSpace = value.replace(regex, '').length;
$('#wordCount').html(wordCount);
$('#totalChars').html(totalChars);
$('#charCount').html(charCount);
$('#charCountNoSpace').html(charCountNoSpace);
};
$(document).ready(function() {
$('#count').click(counter);
$('#text').change(counter);
$('#text').keydown(counter);
$('#text').keypress(counter);
$('#text').keyup(counter);
$('#text').blur(counter);
$('#text').focus(counter);
});
DEMO
Check this link http://jsfiddle.net/vetri/szfgmekm/1/
Pampers Active Baby Tape Style Baby Diapers, Newborn/Extra Small (NB/XS) Size, 72 Count, Adjustable Fit with 5 star skin protection, Up to 5kg Diapers
₹808.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Huggies Complete Comfort Wonder Pants | Pant Style Baby Diapers Large Size (L), 64 Count | India's Fastest Absorbing Diaper, Prevents Diaper Rash, Ideal for 9 to 14 Kgs
₹611.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Little's Premium Baby Diapers XL Size (Extra Large) Pants Style | 12-17 kg | 54 Count | Super Jumbo FluffySoft Baby Diaper with Leakage Guard, Wetness Indicator & 12 Hours Absorption
₹880.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)PROMOM 6-in-1 Baby Bottle Sterilizer & Dryer with Air Filter & LED Controls | Kills 99.9%* Germs in 10 min Cycle | Quick Drying & Storage | Stays Sterile Upto 72hrs*,multicolor, STANDARD WARRANTY PACK ( 1 Year Warranty )
₹4,998.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)LuvLap Moisturising Wipes with Aloe Vera Lid (72 Wipes/Pack, Pack of 3)
₹207.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)One94Store Astronaut Galaxy Projector Night Light – 360° Rotating Nebula Star Projector with Remote Control, Timer & Adjustable Head – Space Lamp for Kids’ Bedroom, Gifts, Gaming Room, Home & Décor
₹599.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Amazon Brand - Supples Premium Baby Diaper Pants | 62 Baby Diapers | Large | 9-14 Kg | 12 Hrs Absorption | Cushiony Cotton Soft Fabric | Phthalates-Free | Triple Leak Guard
₹475.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Hands Free Breast Pump, Wearable Breastfeeding Pump, Lightweight Portable Electric Pump 4 Modes & 12 Suction Levels, Comfortable & Low Noise, 24mm Flange, 1 Pack Pink (STRANDARD)
₹999.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Personalized Baby Photo Frame with First Hair Storage – Custom Name & Birthdate – Premium Wood, 7x7 Inches, Acrylic Cover - Gift for Baby Birthday & New Parents (Pink Baby)
₹298.00 (as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)10 Pcs Silicone Baby Feeding Set for Toddlers 6+ Months | Baby Led Weaning Self Feeding Kit | Suction Plate & Bowl, Bib, Cup, Spoon & Fork, Fruit Feeder, Finger Brush | FDA | Ebook (Pink Bear Plate)
Now retrieving the price.
(as of May 4, 2026 17:26 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)