//判斷輸入ip
$("#agencyIp").blur(function(){
var ip = document.getElementById('agencyIp').value;
var re=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;//正則表達式
if(re.test(ip)){
if( RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256){
$("#agencyIp")[0].className="text easyui-validatebox";
}else {
$("#agencyIp").addClass("wrongtext");
}
}else {
$("#agencyIp").addClass("wrongtext");
}
});
//判斷輸入端口
$("#agencyPort").blur(function(){
var str = document.getElementById('agencyPort').value;
var parten=/^(\d)+$/g;
if(parten.test(str)&&parseInt(str)<=65535&&parseInt(str)>0&&parseInt(str)!=""){
$("#agencyPort")[0].className="text easyui-validatebox";
}else{
$("#agencyPort ").addClass("wrongtext");
}
})
IP,端口驗證
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.