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/
New Mamypoko Pants Premium All Night Absorb| Pant Style Baby Diapers Large Size(L), 62 Count, Ideal for 9-14Kgs|1 Diaper= Upto All Night Absorption now with 10% increased power|Wider Crisscross Sheet|Gentle Coco Care| 12hr Leakage Protection| Prevents Heaviness.
₹567.00 (as of June 17, 2026 23:11 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.)Zest 4 Toyz Baby Play Mat for Babies (1 Year Warranty) Play Gym Floor Mat for Kids with Hanging Rattles Lights & Musical Keyboard Kick and Play Bed | Piano Gifts for New Born Baby - Made in India
₹679.00 (as of June 17, 2026 23:11 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
₹489.00 (as of June 17, 2026 23:11 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.)PAX PARROT Ultra-Soft 6-Layer Muslin Baby Blanket | Soft Cotton Newborn Swaddle Wrap | Lightweight & Breathable | Receiving Blanket & Stroller Cover | 0–3 Years | 110 × 110 cm (Sky Blue Panda)
₹799.00 (as of June 17, 2026 23:11 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.)F4FIVE Baby Tummy Time Water Mat (0–12 Months) – Inflatable Leakproof Sensory Play Gym, Jumbo Ocean Octopus Design, Water-Filled Activity Floor Playmat for Newborns, Infants & Toddlers, Indoor Outdoor Baby Toy & Gift
₹229.00 (as of June 17, 2026 23:11 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.)Mother Sparsh 99% Pure Water (Unscented) Baby Wipes with Lid I Natural Plant made cloth - Super thick Wet Wipes I 72 pcs/pack - Pack of 2 (Super Saver Pack)
₹380.00 (as of June 17, 2026 23:11 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 (VERTICAL)
₹799.00 (as of June 17, 2026 23:11 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.)Pack of 12 Silicone Corner Protectors | Baby Proofing Edge & Corner Guards for Sharp Edges, Table, Bed & Furniture | Child Safety Cushion for Baby Proofing (12)
₹143.00 (as of June 17, 2026 23:11 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.)Baybee Aura Pro Baby Ladder Potty Training Seat for Kids | Foldable Baby Western Toilet Seat with Adjustable Height, Grip Handle & Backrest | Potty Training Seat Chair for Kids 1 to 8 Years (Pink)
Now retrieving the price.
(as of June 17, 2026 23:11 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.)