I am JSF with PrimeFaces 5.1 in my project need onBlur remove specify character i.e in text 01,02,03,, or 01,02,03 or 01,02,03,,,, this text box value I need 01,02,03 using javascript is possible or anyother way
0
votes
2 Answers
1
votes
use this trimRight method: https://www.sitepoint.com/trimming-strings-in-javascript/
String.prototype.trimRight = function(charlist) {
if (charlist === undefined)
charlist = "\s";
return this.replace(new RegExp("[" + charlist + "]+$"), "");
};
console.log("01,02,03,,,".trimRight(','));
'01,02,03,,,,'.replace(new RegExp(/,{1,}$/g),'')- Rayon