将文本值更改为固定格式的javascript [英] javascript for change text value to fixed format

查看:74
本文介绍了将文本值更改为固定格式的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我的表单中有一个数字代码,它由3部分组成.
第一部分是3个数字,然后是6个数字,最后是最后一个数字,例如:

123-456789-0

我可以使文本框为数字.但是,我如何强制我的文本框添加这些括号(-).而maxlengh则用这两个破折号组成了12个字符.

在此先感谢.

Hi every one.

I have a numeric code in my form, that it have 3 parts.
First part is 3 numbers, then 6 numbers, and finaly, the last one, Something like this :

123-456789-0

I can make my text box numeric. But how can i force my text box to add those dahes ( - ). And maxlengh 12 charchters with those 2 dashes.

Thanks in Advance.

推荐答案


您可以使用javascript中的正则表达式来做到这一点
为此尝试此链接将对您有很大帮助
http: //ntt.cc/2008/05/10/over-10-useful-javascript-regular-expression-functions-to-improve-your-web-applications-efficiency.html [

u can do this using regular expression in javascript
for this try this link it will help u lot
http://ntt.cc/2008/05/10/over-10-useful-javascript-regular-expression-functions-to-improve-your-web-applications-efficiency.html[^]

Best luck


这篇关于将文本值更改为固定格式的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆