PHP to add a character to input field

I wanted to know if there is a way to add a comma into an input field that all numbers which has a php validation check for numbers and then checks the string length.

say I want min 6 numbers, max 8 numbers, php validates it, checks strong length,then adds in a comma in the thousand area on the form and when it posts too.

Or can only js do this? IF so, how would that work if PHP is validating and then the js is adding a comma?

You can manipulate data in PHP in pretty much any way you’d like. For your specific number formatting question, this built-in function might help:

http://us2.php.net/number_format

Use js for adding comma on the fly when user enters the data.After that you can remove commas before validating like

 $number_without_comma = str_replace(",","","10,000,00");  

and store it in the database without commas.When you want to display it to the user with commas then use “number_format” as told by “Force Flow” above.