如何格式化文本框输入客户端 [英] how to format textbox entry client side

查看:177
本文介绍了如何格式化文本框输入客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我想掩盖我的文本框,所以如果
用户输入
的数字,例如它的格式为如何做到这一点,任何数字在7位数字。

解决方案

我想你会需要这样的填充功能

你可以听到一个按键,然后一旦被触发,使用 getElementById()元素的内容,然后你可以在其上运行填充函数,并把填充的值放回去。


Q:

I wanna to mask my textbox , so if the user enter the number one for example it formatted as

0000001 how to do this ,any number in 7 digits.

解决方案

I think you are going to need something like this padding function.

You could listen for a keypress then as soon as it is fired, use getElementById() to get your elements content, you could then run the padding function on it and put the padded value back in.

这篇关于如何格式化文本框输入客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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