Current location: Hot Scripts Forums » General Web Coding » JavaScript » Form submission domain restriction


Form submission domain restriction

Reply
  #1 (permalink)  
Old 06-22-04, 05:24 PM
jacobo jacobo is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Form submission domain restriction

Hi, I have a web form with some fields (name, last name, company, email and so on) we want to only allow users to have in their email address, domains such as: @hotmail.com not other email provider will be allowed, we're looking for some javascript alert that validate that form.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 06-22-04, 10:54 PM
dawggy505 dawggy505 is offline
Newbie Coder
 
Join Date: May 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
um. well here is one that makes u enter a valid e-mail address. If u only want @hotmail.com then i don't want to help you...it will draw visitors away with stuf like @cox.net or @yahoo.com.

Code:
 
<form name="validation" onSubmit="return checkbae()">
Email address:<br>
<input type="text" size=18 name="emailcheck">
<input type="submit" value="Submit">
</form>
<script language="JavaScript1.2">
var testresults;
function checkemail(){
var str=document.validation.emailcheck.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true;
else{
alert("Please input a valid email address!")
testresults=false;
}
return (testresults)
}
</script>
<script>
function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true;
}
</script>
Reply With Quote
  #3 (permalink)  
Old 06-23-04, 05:22 AM
jacobo jacobo is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
hi i used this and worked:

<script type="text/javascript">
<!--//
function validate(form){
var goodEmail = /^[\w-]+(@hotmail\.com)$/.test(form.email.value);
if(!goodEmail){
alert('Please enter a valid hotmail email address.');
form.email.value = '';
form.email.focus();
return false;
} return true;
}
//-->
</script>
</head>

<body>
<form method="post" action="" onsubmit="return validate(this)">
Email address: <input type="text" name="email"><br>
<input type="submit" value="Submit">
</form>

------------

thanks for your response.

bye
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Limit the form submission according to time bionicsamir PHP 7 05-09-04 11:10 PM
Form Submission Question Peter_Moore HTML/XHTML/XML 1 04-15-04 09:16 AM
domain check ramez Script Requests 8 03-06-04 11:26 PM
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM


All times are GMT -5. The time now is 10:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.