正则表达式判断ip地址
html:
<div class="configuration">
<form action="" name="myformcon">
<ul>
<li>
<div class="configuration-left">
<div>*</div>
<div><b>监控指标:</b></div>
</div>
<div class="configuration-right">
<input type="radio" name="control" checked><strong>True</strong>
<input type="radio" name="control">False
</div>
</li>
<li>
<div class="configuration-left">
<div></div>
<div><b>FTP IP地址:</b></div>
</div>
<div class="configuration-right">
<input type="text" id="ipname" value="">
<span class=""></span>
</div>
</li>
<li>
<div class="configuration-left">
<div>*</div>
<div><b>转存模式:</b></div>
</div>
<div class="configuration-right">
<select name="" id="">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
<option value="">4</option>
<option value="">5</option>
<option value="">6</option>
</select>
</div>
</li>
</ul>
<div class="buttongroup">
<button>确定</button> <button>取消</button>
</div>
</form>
</div>
css:
.configuration form{
width: 100%;
}
.configuration form ul{
margin-bottom: 20px;
}
.configuration ul,.configuration ul>li{
width: 100%;
list-style: none;
overflow: hidden;
margin:0;
padding:0;
}
.configuration{
width: 100%;
overflow: hidden;
}
.configuration-left{
width: 20%;
height: 40px;
line-height: 40px;
float: left;
overflow: hidden;
}
.configuration-left>div{
float:left;
}
.configuration-left>div:nth-of-type(1){
width: 30px;
height: 40px;
line-height: 40px;
text-align: center;
color:red;
}
.configuration-right{
width:80%;
height: 40px;
float: right;
line-height: 40px;
}
.configuration-right>input[type="radio"]{
width: auto;height: auto;
}
.configuration-right>input,.configuration-right>select{
margin-left: 20px;
margin-right: 5px;
height: 25px;
width: 200px;
}
.configuration-right>span{
visibility:hidden;
}
.configuration-right>.right{
display:inline-block;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
border-radius:50%;
background: #40A740;
color: #fff;
}
.configuration-right>.wrong{
display:inline-block;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
border-radius:50%;
background:#F73636;
color: #fff;
}
.buttongroup{
width:100%;
margin-top: 20px;
padding-left:220px;
}
.buttongroup>button{
padding-left: 20px;
padding-right:20px;
margin-left: 10px;
margin-right: 10px;
}
js:
$(function(){
$("#ipname").blur(change).keydown(change);
function change(e){
var _val = $(this).val();
if( e.type == "blur" || e.keyCode == 13 ){
e.preventDefault();
var reg = /(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])(\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)){3}/;
var res = reg.exec(_val);
if( res != null && _val == res[0]) {
$(this).siblings().css("visibility","visible").attr("class","right").text('✔');
} else {
$(this).siblings().css("visibility","visible").attr("class","wrong").text('✘');
}
}
}
})
实现效果:
本文为本人用来记录自己做的一些东西,如有不对的地方,请见谅。 你是我支撑下去的理由
正则表达式判断ip地址的更多相关文章
- QT正则表达式---针对IP地址
判断合法IP的QT正则表达式: bool IsIPaddress(QString ip) { QRegExp rx2("(//d+)(//.)(//d+)(//.)(//d+)(//.)(/ ...
- C# 正则表达式判断IP,URL等及其解释
C# 正则表达式判断IP,URL等及其解释 判断IP格式方法: public static bool ValidateIPAddress(string ipAddress) { Regex valid ...
- C# 判断ip地址是否正确
最后要用一方法判断ip地址是否正确,直接用.Net现成的类,方法如下: string ipStr="192.168.222.333"; IPAddress ip; if(IPAdd ...
- 正则表达式检测IP地址与端口号是否合法
正则表达式检测IP地址与端口号是否合法,代码如下: 正则表达式检测IP地址 public static bool CheckAddress(string s) { bool isLegal = fal ...
- 使用正则表达式匹配IP地址
IP地址分为4段,以点号分隔.要对IP地址进行匹配,首先要对其进行分析,分成如下部分,分别进行匹配: 第一步:地址分析,正则初判 1.0-9 \d 进行匹配 2.10-99 [1-9]\d 进行匹 ...
- js判断ip地址,子网掩码,网关的逻辑性检查
因为要做静态地址配置的js校验,找了好多资料发现网上都是关于ip,mask的有效性检查,没有ip,submask,gateway的逻辑性判断,自己写下代码供需要的人参考. 普及下网关地址知识: 就是进 ...
- PHP判断ip地址是否合法
1.获取真正ip地址 function get_ip(){ //判断服务器是否允许$_SERVER if(isset($_SERVER)){ if(isset($_SERVER[HTTP_X_FORW ...
- 判断IP地址是否在指定范围内的方法
比如给定一个ip段:127.0.0.1 ~ 127.0.0.255,我们想判断一个给定的ip地址是否在此段内,可以先将ip地址转换成整数,然后整数比较大小就很容易了. 例如: 127.0.0.1 = ...
- python中利用正则表达式匹配ip地址
现在有一道题目,要求利用python中re模块来匹配ip地址,我们应如何着手? 首先能想到的是ip地址是数字,正则表达式是如何匹配数字的呢? \d或[0-9] 对于这个问题,不要一下子上来就写匹配模式 ...
随机推荐
- PortMon(电脑开放端口检查工具) 3.03 免费绿色版
软件名称: PortMon(电脑开放端口检查工具) 3.03 免费绿色版 软件语言: 英文 授权方式: 免费软件 运行环境: Win7 / Vista / Win2003 / WinXP / Win2 ...
- textview设置不同字体大小
<style name="style0"> <item name="android:textSize">19dip</item&g ...
- bayboy下载安装
badboy是jmeter工具的好搭档. 好处体现在那里呢? JMeter是纯Java编写的软件功能和性.能测试工具,其录制脚本过于笨拙和复杂. 而Badboy是用C++开发的动态应用测试工具,其拥有 ...
- javascript 局部变量和全局变量
刚开始学js,遇到了一个奇怪的问题,查找之后知道了答案 需要记住两句话 1 Javascript的变量的scope是根据方法块来划分的(也就是说以function的一对大括号{ }来划分).切记,是f ...
- Linux 相关的error处理
1 dpkg: error: duplicate file trigger interest for filename Notice the first and last lines of /var ...
- 单链表,循环链表,双向链表(C++实现)
首先是单链表(带附加表头),实现类代码如下: template<class T> struct LinkNode{//链表节点 T data; LinkNode *link; LinkNo ...
- Android 发送HTTP GET POST 请求以及通过 MultipartEntityBuilder 上传文件(二)
Android 发送HTTP GET POST 请求以及通过 MultipartEntityBuilder 上传文件第二版 上次粗略的写了相同功能的代码,这次整理修复了之前的一些BUG,结构也大量修改 ...
- Tomcat server.xml UTF-8配置
Tomcat server.xml UTF-8配置 <Connector port="8080" maxThreads="150" minSpareThr ...
- express学习点滴- session()和cookieSession()的区别
express 里提供了两种有关session的中间件 * session() 提供了内存和数据库两种方式保存session.具体两种session原理请自行学习,不进行展开了.自己也是一知半解... ...
- AVFoundation--AVPlayer
// // AVPlayerNetViewController.m // PodsTest // // Created by ZhuYi on 16/4/29. // Copyright © 2016 ...