I need to create input mask to format date / ssn / currency. I see examples but wish to understand the / d* so I can figure out what Exactly wont my site to do.
@Tweak4Jul 03.2007 — #There are no input masks in JS. You can use regular expressions (the "/ d*" that you mentioned, though that is only part of one) in order to validate input, but the "masks" that exist in some other languages are absent in JS.
And for what it's worth, /d*/ would look for zero or more numeric characters ?
@nhnerdauthorJul 04.2007 — #I need to process severial currency (money) feilds that reange from 1,000.00 to 100,000,000.00 and any where in between, when the user leaves the feild I wish to format any entry with the proper $,,,. format. I found JS to do the SS and phone numbers this way. but with the currency I noticed I have to loop through and detect the exact sets of (3). what happens now is if you place 25000 in it will change to $25,000. but if I tab back and out it will drop to 250. and so on. is there an easier why to do this then looping through 100,000,000. / 1,000,000. / 1,000. and so on,
@Tweak4Jul 09.2007 — #If you post the function you are using to do this, we can probably help tweak it. On my company's site, we do something similar to this for formatting currency fields. In our usage, the first step of the format is to strip out any non-numeric fields- from there is is a simple matter to add commas where necessary.
// check for decimal points ans if greater then 1 point stop and turn default values if (splitvalues[2] != null) { t.value = "To many . in " + t.value; return; }
// check valid range of deciaml number var dnumberExp = new RegExp('([0-9]{2})');