- //判断输入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");
- }
- })
来源: http://www.bubuko.com/infodetail-1991045.html