Validate input - IP adress


Hi, in my app, i need to validate input from user, but i need to check, if the input is correct ip adress. How can i do that, in a most simple way?



function ValidateIPaddress(ipaddress) {  
  if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {  
    return (true)  
  alert("You have entered an invalid IP address!")  
  return (false)  

Apart from pattern validator in angular js you can also use this function for tracking that passed input value is valid IP or not.