Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting numbers 1

Status
Not open for further replies.

omegabeta

Programmer
Joined
Aug 20, 2003
Messages
148
Location
RO
I want to enter numbers like this: 999.999.999,99 in a HTML form.
How can I make a "mask" like this so that when the user must complete a field on the Web page to see . . ,

Thanks in advance.
 
omegabeta,

One way is to break your elements into four separate text fields.

Assuming your numbers set the max field lengths then set the <input type=&quot;text&quot; maxlength=&quot;3&quot;> or whatever it is.

You could use vbscript or javascript to test the field for numbers with the mouseout event as an example to test it.

You could display/insert the appropriate periods or comma's between the appropriate <input type=&quot;text&quot;>

<input type=&quot;text&quot; name=&quot;f1&quot; maxlength=&quot;3&quot;>.<input type=&quot;text&quot; name=&quot;f2&quot; maxlength=&quot;3&quot;>.<input type=&quot;text&quot; name=&quot;f3&quot; maxlength=&quot;3&quot;>,<input type=&quot;text&quot; name=&quot;f4&quot; maxlength=&quot;2&quot;>

There might be a way to do this as an ActiveX COM or maybe .HTA, but that is out of my league.

The other alternative is to use the onSubmit or onMouseOut to trigger appropriate validations.

BTW, with Javascript you could test the # char's and jump the user to the next field, trigger the onMouseOut to do validation, which I would use regex. Simpler to do and maintain. Also, Javascript is supported by most browsers, VBScript only on IE.

HTH
DougCranston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top