Forum Moderators: open

Message Too Old, No Replies

email validation with a twist!

I need to strictly block certain email addresses

         

benji

4:23 pm on Jun 1, 2009 (gmt 0)

10+ Year Member



I use J/Script validation on a form.
All seems to work well for me - thanks to Webmasterworld.com!

I keep getting emails from a person using very similar email address to my own (obviously someone I know).

The question is, how can I give them a special Javascript message, if using certain email addresses. Let's assume the email address is:

myemail@here.com

The RegExp I already have in place is:

var emailRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

I know haw to set the message etc, but can't quite seem to get the speacial email to throw the message up..

I thought replacing the a-zA-Z0-9 with myemail would work, but it doesn't.

All help much appreciated.

benji

4:28 pm on Jun 1, 2009 (gmt 0)

10+ Year Member



PS - just a thought....
Is there any way of catching someone's IP address through a contact form?

whoisgregg

10:51 pm on Jun 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello benji,

Not directly, but you can use the server side language of your choice to pass that information to your javascript. For PHP something like this would work:

<script type="text/javascript">
var user_ip = '<?php echo $_SERVER['REMOTE_ADDR']; ?>';
alert(user_ip); // testing only, use this variable in your existing function
</script>

To block certain email addresses, you'd want to do a separate check from the one to validate the format of the email address. If you post a snippet of your code, we should be able to recommend a place to do so.