Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Additional validation needed for Front Page Form Fields

Status
Not open for further replies.

sharkatek

Programmer
Mar 11, 2005
51
I am using a simple Front Page form and am able to capture the IP address by checking the Remote Name box on the saved fields dialog box, but is there any way to validate with additional javascript code to keep a specific IP address from accessing the page?

I am not using a database or ASP, just a simple Front Page form and I have a rogue person accessing the page and the only identifiable info I get is the IP address.
Unfortunately, the IP address is not one of the FORM FIELDS that has a name, so I cannot use the Front Page validation utility.

I would like to redirect them to a specific page of my site that tells them they are blocked. I need to use the Front Page form, so please include information about where to place the script.

Also if there is no way to do this, is there any way to use javascript to further validate normal Front Page form fields? The built-in validation only gives me TWO blanks to say equal to or not equal to.

Thank-you in advance! Sharkatek
 
Try something like this:

Code:
<script type="text/javascript">

	// List all the IPs you wish to ban, seperate each with a comma.
	var bannedIPs = ["123.123.123.123", "456.456.456.456"]

	var ip = '<!--#echo var="REMOTE_ADDR"-->'

	var sortEmOut = bannedIPs.join("|")
	sortEmOut = new RegExp(sortEmOut, "i")

	if (ip.search(sortEmOut)! = -1){ 
	alert("You have been blocked from this site, you are being redirected...")
	window.location.replace("[URL unfurl="true"]http://www.yahoo.com")[/URL]
	}

</script>

-
Mike
FREE CGI/Perl/JavaScripts
 
If you can't do it using a server-side solution (as above), then you're gonna be out of luck, I reckon. There is no way to get the IP address using Javascript directly.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Thank-you, Mike - I'll try it out. This looks like it will work for the multiple value validation problem if not the IP address.

Thank-you also Jeff.

Diane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top