javascript中的正则表达式允许退格 [英] regular expression in javascript which allows backspace

查看:34
本文介绍了javascript中的正则表达式允许退格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的允许字符、数字、点和下划线的正则表达式是

My regular expression which allows characters, numbers, dot and underscore is

var numericReg = /^[a-zA-Z0-9\._]+$/;

我怎么能在这个正则例子中允许退格?

How could i allow backspace in this reg ex.?

推荐答案

此问题的最佳解决方案是在验证之前检查 textbox >0 的值.这将有助于解决在空文本框中按退格键时显示的错误..!!

The optimal solution for this problem is to check the value of textbox >0 before validating. This will help to solve error showing while pressing backspace in an empty textbox..!!

这篇关于javascript中的正则表达式允许退格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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