Hi all, advance thanks.
I want to add commas > , < every 10 characters in a form input text area when typing in this textarea.
Ex : 4584789568,4578545265,2487589564,3589546826,4581256478
Can anyone help me ?
thanks
Hi all, advance thanks.
I want to add commas > , < every 10 characters in a form input text area when typing in this textarea.
Ex : 4584789568,4578545265,2487589564,3589546826,4581256478
Can anyone help me ?
thanks
Made it now in a hurry, i dont really know if it really is that efficient the way i did it now, maybe there are faster methods.
Hope it is good. Cheers
Result: 4584789568,8954682645,1268264581,4581268264,8126826458,2682645812,6478
[php]
[/php]
Hi zetcoby,
Thank you for replay, Your php script are working, but its get comma only after form/value submit. Actually i was get a javascript code for as my need.
<script type="text/javascript">
function format(input)
{
var nStr = input.value + '';
nStr = nStr.replace( /\,/g, "");
var x = nStr.split( '.' );
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{10})/;
while ( rgx.test(x1) ) {
x1 = x1.replace( rgx, '$1' + ',' + '$2' );
}
input.value = x1 + x2;
}
</script>
<textarea id="" name="" class="" rows="5" cols="50" onkeyup="format(this)" ></textarea>
It is automatically add comma every 10 digits when we typing in textarea.
Thanks.
Ups, somehow i skipped the part where u say “when typing in this textarea.” my bad.
oh and only now i realize that i am in the javascript & ajax category… idk i think i was to drunk last night xD