Answer the question
In order to leave comments, you need to log in
How to implement captcha using JWT tokens?
JWT cannot store sensitive data as it is easy to decrypt. How to store captcha data in this case? Or, for example, how to implement a rate limit bound to a token and ip?
Answer the question
In order to leave comments, you need to log in
Like this: https://jsfiddle.net/IonDen/55665p35/
function prettify (num) {
var n = num.toString();
var separator = " ";
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + separator);
}
var $test = $(".test");
var val = $test.prop("value");
$test.prop("value", prettify(val));
Another option.
Formats blur.
When changed, spaces are removed and can be adjusted.
thanks to Denis Ineshin for the regular expression.
codepen.io/alexanderkshnyakin/pen/NNorZz
const numb = 1234567;
const numbFmt = new Intl.NumberFormat('ru-RU').format(numb);
console.log('Отформатированное число: ' + numbFmt); // 1 234 567
const numb = 1234567;
const numbFmt = numb.toLocaleString('ru-RU');
console.log('Отформатированное число: ' + numbFmt); // 1 234 567
The previous methods don't work well for very large numbers, so here's mine:
console.log(
"498065392975507667366026341067548906436328316841307936116457316164193184705285250962660148627300967657213217328759941177315742017903027130095729437206958025287403606910196074469378649164695055964366281024547871829070617652494336"
.split("")
.reverse()
.join("")
.replace(/\d\d\d/g, "$& ")
.split("")
.reverse()
.join("")
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question