`
musicbox95351
  • 浏览: 229307 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

WAP 手机 输入框的格式限制

    博客分类:
  • WAP
 
阅读更多
可以让用户只能输入数字、大写字母、小写字母
对于手机上的输入框的格式限制还是太简单了些。没办法。

以下来源
http://blog.mant.com.cn/?action=show&id=416
对于作者提到的输入小数的问题我打算将一个输入框分成两个处理。如果不对文本框输入内容做限制,用户输入数字时切换输入法相当麻烦。


引用

The -wap-input-format WCSS property takes a number of format characters as its value. The format characters specify the type and number of characters that can be entered in a text field. The -wap-input-format WCSS property should be applied to the <input type=”text”>, <input type=”password”> and <textarea> tags. There will be no effect if it is applied to other XHTML MP tags. The property value of -wap-input-format is called the input mask.

The following table shows the format characters available (format characters are case-sensitive):
Format characters Usage
a It is used to represent any lowercase letter or symbolic character.
A It is used to represent any uppercase letter or symbolic character.
n It is used to represent any numeric or symbolic character.
N It is used to represent any numeric character.
x It is used to represent any lowercase letter, numeric or symbolic character.
X It is used to represent any uppercase letter, numeric or symbolic character.
m It is used to represent any character. The WAP browser is in lowercase input mode by default but can be changed to uppercase input mode.
M It is used to represent any character. The WAP browser is in uppercase input mode by default but can be changed to lowercase input mode.



Here are two WAP CSS examples that illustrate the usage of the -wap-input-format property:

-wap-input-format: “NN”

Meaning: You must enter 2 numeric characters in a text field with this WAP CSS style rule applied.

-wap-input-format: “AAAAA”

Meaning: You must enter 5 uppercase letters or symbolic characters in a text field with this WAP CSS style rule applied.

The input mask must be enclosed in double quotes or single quotes since the -wap-input-format property takes a string value. Note that single quotes do not work in Openwave Mobile Browser 6.2.2. For example, the following markup does not work properly in Openwave Mobile Browser 6.2.2:

<input type=”text” style=”-wap-input-format: ‘N’”/>

You have to change it to the following markup so that the input mask is enclosed in double quotes:

<input type=”text” style=’-wap-input-format: “N”‘/>

It is a good practice to set an input mask for an input field, since the input mode (alphanumeric mode, numeric mode, etc) of a mobile phone’s keypad will be set automatically according to the input mask. It is a very convenient feature for the users of your mobile Internet application. For example, if the input mask is “NN” (it specifies that the text field can only accept 2 numeric characters), a mobile phone’s keypad will be set to numeric mode automatically. If you press a key of the mobile phone, no alphabets or symbols can be outputted.

You can add a single numeric character before a format character in an input mask. For example:

-wap-input-format: “2N”

It means a user can enter a maximum of 2 numeric characters in a text field. (Notice that the meaning of “2N” is different from that of “NN”.)

Also, you can add the * character before a format character in an input mask. For example:

-wap-input-format: “*N”

It means there is no limit in the number of numeric characters that can be entered.

Another example is:

-wap-input-format: “A*a”

It means the user must:

    enter one uppercase character (or symbolic character), and then
    enter zero or more lowercase character (or symbolic character)

The input mask “A*a” can be applied to text fields that are used to obtain a name from the user. It ensures that the first character must be in uppercase. For example, the user can only enter “Peter” but not “peter”.

The default value of the -wap-input-format WCSS property is “*M”.

The following two rules should be followed when adding a numeric character or the * character before a format character:

    You can only use such character combination once in the input mask.
    You can only use such character combination at the end of the input mask.

Here are some examples of invalid WCSS style rule:

    -wap-input-format: “9N9N” — Reason: You can only use 9N once in the input mask.
    -wap-input-format: “*Naa*N” — Reason: You can only use *N once in the input mask.
    -wap-input-format: “9NNNN” — Reason: You can only use 9N at the end of the input mask. The correct format should be “NNN9N”.
    -wap-input-format: “*NA” — Reason: You can only use *N at the end of the input mask.

If a value of invalid syntax is assigned to the -wap-input-format property, WAP browsers will ignore the property.

Escaped characters can be included in an input mask. To escape a character, you put two backslashes (i.e. ) in front of that character. (Note: The Openwave Mobile Browser 6.2.2 does not follow the correct WCSS language syntax. It uses a single backslash for character escaping.)

Why do we need escaped characters in the input mask? Look at this example and you will understand. Let’s say you want a user to enter a date of the form MM/DD/YYYY and you specify “NN/NN/NNNN” (or “NN/NN/NNNN” for Openwave Mobile Browser 6.2.2) as the input mask. If the user use Openwave Mobile Browser, the / character will be inserted automatically at the third and the sixth character position of the text field as he/she types the date. If the user use the Nokia Mobile Browser, the / character will not be inserted automatically but the browser will forbid the user to enter characters other than / at the third and the sixth character positions. The input mask in this example ensures that the third and sixth characters must be /.

(A note for mobile Internet application developers who are familiar with WML 1.x:

Character escaping in the -wap-input-format property value is different from that in the format attribute value of WML 1.x. Two backslashes are used to escape a character in the -wap-input-format property value while a single backslash is used for the same purpose in the format attribute value. For example, the following XHTML MP markup:

<input type=”text” style=’-wap-input-format: “bN”‘/>

is equivalent to the following WML 1.x markup:

<input type=”text” format=”bN”/>

You have to use two backslashes in WCSS because a backslash is a special character in the WCSS language. To let a backslash character to be part of a property value, it has to be escaped by another backslash. This means if you specify -wap-input-format: “bN” in the cascading style sheet, the WCSS processor will treat it as -wap-input-format: “bN”.)



我使用的结果还可以,但是只能是纯数字,不能输入小数点,纠结啊...
分享到:
评论

相关推荐

    手机wap版日期输入框

    首先,手机WAP版日期输入框的设计应考虑到移动设备的屏幕尺寸限制和触摸操作的特点。在小屏幕上,传统的文本输入方式可能会导致用户难以精确输入日期,因此,引入日期选择器成为了解决问题的关键。这种选择器通常以...

    wap手机端登录html模板下载_wap 手机 登录 login 移动端 注册.zip

    在WAP手机端登录模板中,设计者必须考虑到移动设备的特性,如小屏幕尺寸、有限的输入方式以及可能的网络速度限制。因此,该模板会注重简洁、高效的设计原则,以便用户快速完成登录或注册流程。 1. **响应式设计**:...

    Amaze UI 手机wap登录页html模板_Amaze UI 手机 登录 login 注册 wap.rar

    同时,考虑到移动设备的输入限制,模板可能会优化输入框的键盘类型,比如为手机号码输入框显示数字键盘。 总的来说,"Amaze UI 手机wap登录页html模板"是一个集成了 Amaze UI 前端框架的登录和注册页面模板,它提供...

    手机wrap网站要出发触屏版手机wap用户登陆网站模板

    - **加载速度优化**:考虑到移动网络的速度限制,触屏版WAP网站会特别注重页面加载速度的优化,比如减少图片大小、压缩代码等。 ### 三、手机WAP用户登录网站模板的作用与意义 该模板主要用于帮助开发者快速构建...

    手机wap源码模板 (38).zip

    在手机WAP网站上,表单设计必须考虑到屏幕尺寸限制和触摸输入特性。这两份文件展示了输入框、选择器、复选框、单选按钮等常见元素的布局和样式,以及表单验证和提交功能的实现方法。理解这些细节有助于创建符合移动...

    仿手机号码归属地查询触屏版手机wap查询网站模板源码

    API调用可能需要API密钥,且需要处理请求参数(如手机号码)和处理返回的JSON或XML格式的数据。 - 数据可能包括运营商信息(如中国移动、中国联通、中国电信),归属地(省份和城市),以及可能是虚拟运营商的信息...

    wap端,生日,日期插件

    在wap端开发中,考虑到网络环境和设备性能的限制,datePicker插件需要优化加载速度和运行效率。开发者可能采用懒加载策略,只在需要时才加载插件,同时对代码进行压缩和优化,减少内存占用和CPU资源消耗。此外,为了...

    手机wap源码模板 (542).zip

    【标题】"手机wap源码模板 (542).zip" 涵盖了一系列用于构建移动Web应用的源代码文件,这些源代码是为适应WAP(无线应用协议)技术而设计的,主要针对手机和其他移动设备。WAP是一种允许在移动设备上访问互联网内容...

    wap简单留言论坛

    在互联网尚未普及智能手机和平板电脑的年代,WAP技术为非智能移动电话提供了浏览网页和参与互动的方式。这个“难得的源码”可能是指一个开源项目,允许开发者查看和修改其底层代码,以便定制或改进功能,适应不同...

    HTML手机用户注册登录页面模板.zip

    输入框应该具有合理的占位符文本,且对输入类型进行限制,如手机号码、邮箱地址等。密码输入框应提供显示/隐藏密码的功能,增强安全性。 3. **验证机制**:为了防止无效数据提交,表单需包含前端验证,例如检查...

    ASP源码—陌落搜索引擎爬虫 WAP搜索.zip

    WAP是一种专为移动设备如手机和平板电脑设计的通信协议,它允许用户通过移动网络访问互联网服务。 在ASP源码中,开发者可能使用了VBScript脚本语言来编写程序逻辑,这包括了数据抓取、解析和存储的各个部分。搜索...

    手机 pdf 阅读器

    (对于NOKIA手机及其它部分手机,由于安全策略的限制,在Anyview的文件管理器中无法查看后缀为.jar的文件) 自定义问候语(系统路径下dictum.rc文件,格式参见jar包中的dictum.rc文件,保存时使用UTF-8编码,可写条目为...

    手机开发J2ME资料大全

    配置定义了Java虚拟机(JVM)的基本特性和内存限制,而profile则定义了一组特定设备的应用程序接口(API)。常见的配置有CLDC(Connected Limited Device Configuration)和CDC(Connected Device Configuration),...

    深入MIDP2.0(1) - 谈生命周期与安全性

    MIDP 2.0提供了基础的用户界面组件,如表单、按钮、文本输入框等,通过Canvas和Form类实现。开发者可以创建自定义图形和交互式UI。 6. **网络连接**: MIDP 2.0支持通过HTTP和WAP协议进行网络通信,允许MIDlets...

    j2me通讯录

    这需要通过HTTP或WAP等协议进行网络通信,可能涉及XML或JSON格式的数据交换。 5. **安全性和隐私**:作为个人信息管理工具,通讯录应用应考虑数据保护,确保用户信息的安全,例如,对敏感信息进行加密存储。 6. **...

    蚂蚁分类信息系统

    增加手机信息页以及商家页分享微信分享朋友圈的功能7,信息分类列表页的标题改进8,修正手机版里输入框检测重复时,窗口不停弹出无法关闭的BUG9,修正违禁词语出现后信息不自动转待审的问题10,增加手机端找回用户...

    JAVAWML信息查询与后端信息发布系统实现——WML信息查询设计(源代码+论文).zip

    Java WML信息查询与后端信息发布系统是一种基于Java技术实现的移动互联网应用,主要用于在WAP(无线应用协议)设备上进行数据检索和发布。WML(Wireless Markup Language)是一种专为低带宽无线设备设计的标记语言,...

    phpind8.7 html页面文件说明

    - 限制普通用户访问,只有特定用户(如创始人)才能登录。 - 可能包含论坛关闭原因说明及后续计划。 #### 8. **Birth.htm - 生日会员列表,用于首页** - **描述**:展示近期生日会员名单,通常位于网站首页。 - *...

    html5移动开发之密码键盘

    JavaScript则负责键盘的交互逻辑,如按键响应、焦点管理以及输入限制等。 3. **触屏事件处理**:为了确保在触摸设备上的良好用户体验,需要适配`touchstart`、`touchmove`和`touchend`等触屏事件。 4. **安全存储*...

Global site tag (gtag.js) - Google Analytics