Validate user IP address using javascript

1. Read user IP address. var ip = '<!--#echo var="REMOTE_ADDR"-->' 2. Enter list of allowed ips var allowed_ips = ["",""] 3. Create a regular expression string. var handleips = allowed_ips.join("|") handleips = new RegExp(handleips, "i") 4. Check condition whether user IP address is in allowed list if (!=-1)     alert("done") else     alert("Unauthorized access");


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>

More information about formatting options