Home  >  Article  >  php教程  >  php锁定文本框内容的方法

php锁定文本框内容的方法

WBOY
WBOYOriginal
2016-06-06 19:55:511380browse

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 有时候我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如input type="text" name="zg" value="中国" 的内容,"中国"两个字不可以修改,有三种方法。 方法1: onfocus=this.blur() inpu

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  有时候我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如 的内容,"中国"两个字不可以修改,有三种方法。

  方法1: onfocus=this.blur()

  

  方法2:readonly

  

  

  方法3: disabled

  

  下面分别是readonly和disabled的效果截图:

php锁定文本框内容的方法

  ****************************************************************************************

  应用案例:

php锁定文本框内容的方法

  [html] view plaincopy

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

登录密码: * 当前的登录密码
真实姓名:

  

* 请输入您的真实姓名
身份证号:

  

* 请输入您的身份证号

  

  从数据库中读出姓名,当姓名修改提交后,把数据库中的ustat字段设置为1,刷新页面后,当检测到son[ustat]==1时,添加属性readonly,防止用户再次修改文本框内容。

php锁定文本框内容的方法

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn