表单验证时,需要去除文本框前后的空格才可以正确通过验证。以前看到过一句话:任何设计和代码都要对用户足够宽容。

<input type="text" class="phone">
<input type="button" id="btn" value="过滤"> jQuery - $.trim()
var tel = $('.phone').val();
var result = $.trim(tel); JS - replace&正则
var tel = document.querySelector('.phone').value;
var result = tel.replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,'');

  

最新文章

  1. 二叉树的创建和遍历(C版和java版)
  2. Android popupwindow使用心得(一)
  3. activiti工作流的web流程设计器整合视频教程 SSM 和 独立部署
  4. Angular Mobile UI API文档
  5. Ngui中Sprite,SlicedSprite,Tiled Sprite,FilledSprite的区别
  6. 跟着百度学PHP[4]OOP面对对象编程-10-静态关键字static
  7. 水流雨渍shader
  8. Java对象初始化详解
  9. 纯原生js移动端城市选择插件
  10. Xcode8.3 添加iOS10.3以下旧版本模拟器
  11. mysql启动时报错:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid) 的解决方法
  12. canvas图形编辑器
  13. [逆向工程] 二进制拆弹Binary Bombs 快乐拆弹 详解
  14. asp+SqlServer2008开发【第四集:windows server 2008 r2的操作记录】
  15. android抽屉效果
  16. [LeetCode] Shortest Word Distance I &amp; II &amp; III
  17. 伸展树(Splay Tree)进阶 - 从原理到实现
  18. air for android 使用ANE来获取安卓手机IMEI号
  19. C++编写DLL动态链接库的步骤与实现方法
  20. Scrum 项目2.0 3.0

热门文章

  1. Java同步容器总结
  2. Hive搭建与简单使用
  3. POJ 1985 求树的直径 两边搜OR DP
  4. ACM_鸡兔同笼(二元一次方程)
  5. String和八种基本数据类型互相转换
  6. linux下常用命令失效
  7. 富文本wangEditor的批量激活
  8. redis-linux
  9. token session cookie
  10. brew 安装的.net 运行时提示&quot;Did you mean to run dotnet SDK commands?&quot;