Thursday 23 February 2017

jQuery validation - IP address


/* 
 ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
 ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";
*/
$.validator.addMethod('ipChecking', function(value) {
 //var ip = "^(?:(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)\.){3}" +"(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)$";
 validIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
 ipCheckFlag = true;
 ipLists = value.split(',');
 for(ip=0; ip<ipLists.length; ip++){
  if(!ipLists[ip].trim().match(validIpAddressRegex)){
   ipCheckFlag = false;
  }
 }
 return ipCheckFlag;  
});

3 comments:


  1. This is really a good source of information, I will often follow it to know more information and expand my knowledge, I think everyone should know it, thanks Best voip phone system for small business service provider

    ReplyDelete
  2. Hi there I am so thrilled I found your website, I really found you by mistake, while I was browsing on Yahoo for something else voip solutions for small business

    ReplyDelete
  3. There are no unforeseen international roaming fees—Even those who do receive significant international roaming bills are aware that using their home phone abroad is expensive. SIM Card security

    ReplyDelete

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push