By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

validate email domain in object string

P: 11
I am trying to validate the suffix of an email address for a string entered into a form to ensure it contains the correct domain. Some of the code i am currently using looks like this for blank entries

if email="" then
response.redirect "STS_form.asp?msg=Please enter your EMAIL!" & querystr
end if

but i want to make sure that the email string contains the text "" and if not then redirect back to the form page.

So if i were to enter "" i would be redirected back to the form to enter a valid email address. If i entered "" then the process would continue to the next if statement.

I have tried to use the search and match statements with no avail. please help!

If you need to see more of my code, please let me know.

Apr 15 '09 #1
Share this Question
Share on Google+
2 Replies

P: 2,476
use regular expression.
Expand|Select|Wrap|Line Numbers
  1. var domain_pattern = /$/;
  2. var email_id = 'your email id';
  3. alert(domain_pattern.test(email_id));
Apr 15 '09 #2

P: 2,476
You can also do it by using "String.indexOf". Actually there should be a function like "String.endsWith" and "String.startsWith".
Here you can write own "String.endsWith" function like ..

Expand|Select|Wrap|Line Numbers
  1. String.prototype.endsWith = function(str){
  2.  return this.indexOf(str)==this.length-str.length;
  3. }
Apr 17 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.