placeholder和json两种实现登录隐藏的方法
来源:互联网 发布:中银淘宝校园卡申请 编辑:程序博客网 时间:2024/06/15 04:45
<head> <title> placeholder和json两种实现登录隐藏的方法 </title> <script type="text/javascript"> //判断浏览器是否支持 placeholder属性 function isPlaceholder() { var input = document.createElement('input'); return 'placeholder' in input; } if (!isPlaceholder()) { //不支持placeholder 用jquery来完成 $(document).ready(function() { if (!isPlaceholder()) { $("input").not("input[type='password']").each( //把input绑定事件 排除password框 function() { if ($(this).val() == "" && $(this).attr("placeholder") != "") { $(this).val($(this).attr("placeholder")); $(this).focus(function() { if ($(this).val() == $(this).attr("placeholder")) $(this).val(""); }); $(this).blur(function() { if ($(this).val() == "") $(this).val($(this).attr("placeholder")); }); } }); //对password框的特殊处理1.创建一个text框 2获取焦点和失去焦点的时候切换 var pwdField = $("input[type=password]"); var pwdVal = pwdField.attr('placeholder'); pwdField.after('<input class="password" id="pwdPlaceholder" type="text" value=' + pwdVal + ' autocomplete="off" />'); var pwdPlaceholder = $('#pwdPlaceholder'); pwdPlaceholder.show(); pwdField.hide(); pwdPlaceholder.focus(function() { pwdPlaceholder.hide(); pwdField.show(); pwdField.focus(); }); pwdField.blur(function() { if (pwdField.val() == '') { pwdPlaceholder.show(); pwdField.hide(); } }); } }); } </script></head><body> <input class="username" placeholder="用户名" type="text" id="accountId" name="operId" maxlength="20" style="ime-mode:disabled;" /> </br> <input class="password" placeholder="密码" type="password" id="pwdId" name="pwd" maxlength="20" style="ime-mode:disabled;" /></body>
placeholder和json两种实现登录隐藏的方法,当浏览器不支持placeholder时,可以用json来实现登录用户名密码的隐藏
1 3
- placeholder和json两种实现登录隐藏的方法
- Placeholder的两种实现方法
- PlaceHolder的两种实现方式,表单
- PlaceHolder的两种实现方式
- jsp中实现参数隐藏的两种方法
- iOS控件TextView添加placeholder属性的两种方法
- PlaceHolder的两种实现方式(输入框提示)
- Activity全屏和隐藏标题栏的两种方法。
- 实现Windows XP自动登录的两种方法
- 实现电脑自动登录的两种方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- ThinkPHP通过AJAX返回JSON的两种实现方法
- HDU 4886 TIANKENG’s restaurant(Ⅱ) hash+dfs
- Linux分区注意点
- com.genuitec.runtime.generic.jee60 is not defined
- apache 403错误 显示如下: You don't have permission to access / on this server. 解决办法
- 临界区,互斥量,信号量,事件的区别(线程同步)
- placeholder和json两种实现登录隐藏的方法
- freemaker的语法问题
- Ultra-QuickSort(树状数组 + 离散化)
- 文件工具
- CAS单点登陆实践
- latex多幅图片排列 2*2示例
- 哈希表
- 求每年最高气温
- 指针和数组——(个人笔记)