Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have a masked numeric input field?

I am creating an HTML5 application on an Android and for this specific scenario, we have an input field that is for a credit card's security code and we want to force the input field to be numberic only and masked.

I have had no luck searching for this specific case and from everything I can tell from researching/trying it out for myself is that this can't be done purely through HTML5 (since number and password are both options for type and only one type can be used). Am I missing something and there is a way to pop-up the numeric keyboard while having the input be masked through HTML5 or is there another way to force the keyboard input type or masking the input through CSS or JavaScript?

Thanks for any help!

like image 582
JakeW Avatar asked Nov 30 '11 21:11

JakeW


People also ask

How do I create a masked input?

In the Navigation Pane, right-click the object and click Design View on the shortcut menu. Click the field where you want to create the custom input mask. In the Field Properties area, click the Input Mask text box, and then type your custom mask. Press CTRL+S to save your changes.

How do you create an input mask in Excel?

1. Right-click the cell where you want to create a mask input (here, cell B2), and choose Format Cells… 2. In the Format Cells window, (1) choose Custom category, (2) enter #”:”00 in the Type box, and (3) click OK.

What is input masking Javascript?

The InputMask control allows you to validate and format user input as it is entered, preventing users from entering invalid data. To use the control, set the mask property to a string that specifies the valid character classes for each input position. The character classes are described in the API documentation.


1 Answers

If it's only required to work in WebKit based browsers, and CSS is allowed in 'purely through HTML5', you could try:

input[type=number] {     -webkit-text-security: disc; } 

I'm not sure if there's currently any equivalent for other browsers, in the future this may be controllable through the appearance CSS property. The CSS3 version of appearance has been dropped from the spec, so it looks like you'll have to wait for the standardization of text-security for a cross browser solution.

like image 154
robertc Avatar answered Sep 19 '22 13:09

robertc