It is not possible for me to write a sample for you. But I'll guide you
You can detect IP using jQuery AJAX
Get Client Machine IP Address using JQuery and JSON
Then you need you can check it in javascript or additionally pass as parameter to your function