...

View Full Version : Age-check with an email verification javascript? for simple htm



Chozin
07-04-2006, 11:52 PM
Chozin here,
does any one here that can help me with a simple java script i can use, that
ask for your b-date and an email address then if both are ok then it let's you enter, if age does'nt match the criteria or the e-mail doesn't verify then it returns to the page again but if they try three time it redirect to another website with out adult content that i made. this is what i got but when i try to merge them i get error. first age-check and Email-verification
age-check
age-check.js:
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
};

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
};

if ( readCookie('OVER_18') != 'yes' )
{
var over_18 = confirm('You are about to view adult sexlife, which includes some products ' +
'intended for adults. You must be 18 or 21 years old (depending on your location) to ' +
'view the site. Click OK to indicate you are of legal age, and are not offended by ' +
'adult products. To be redirected to Kids life, our general site, click Cancel.');

if ( over_18 )
{
createCookie( 'OVER_18', 'yes' );
} else {
window.location = '/-18_index.html';
}; };

age-check.html:

<form action="" method="post">
<select name="dob_month" tabindex="1">
<option value="01" selected="selected">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">Jun</option>
<option value="07">Jul</option>
<option value="08">Aug</option>
<option value="09">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
<input type="text" name="dob_day" value="dd" size="2" maxlength="2" tabindex="2" onfocus="if(this.value=='dd')this.value='';" onblur="if(this.value=='')this.value='dd';" />
<input type="text" name="dob_year" value="year" size="4" maxlength="4" tabindex="3" onfocus="if(this.value=='year')this.value='';" onblur="if(this.value=='')this.value='year';" />
<br /><br />
<input type="checkbox" name="remember" value="1" checked />
<small>Don't ask me again</small>
<br /><br />
<input type="submit" name="dob_submit" value="Click to submit your electronic signature" tabindex="4" />
</form>
<p class="disclaimer">
Access by minors is strictly forbidden. If you are a minor or are not interested in our adult products, please go to our non-adult website, <a href="/index.html">Kids life</a> website.
</p>

now i got this Email Verify:
<script language="javascript">

function Submitform()

{

if (document.sub.addr.value=='') alert("Invalid Email Address");

else {

if ( ((document.sub.addr.value.indexOf('@',1))==-1)||(document.sub.addr.value.indexOf('.',1))==-1 )

alert("Invalid Email Address");



else document.sub.submit();

}

}

</script>

html:

<td width="50%" align="center" bgcolor="#9F0018">
<p><font face="Verdana" size="2" color="#FFFFFF"><b>Enter your Email Address</b></font></p>
<form action="" method="POST">
<input type="text" name="addr" maxlength="250" size="30">
<input type="hidden" name="type" value="inscription">
<input type="submit" value="Go !" onclick=Submitform()>
</form>
<p align="center">&nbsp;</p>
<p align="center"><a class="tools" href="mailto:name@domain.com?subject=&lt;&lt;&lt;Members_Question&gt;&gt;&gt;"><b><font face="Arial" color="#FFFF00" size="5">E-mail Support</font></b></a></p>

is there a way i can merge these to so that the submit depends on both the b-date and email with only 1 type of submit
thanks in advance.

Lordrea
07-05-2006, 12:36 AM
Kinda like this? (I havn't checked it, so don't depend on it)

<script language="javascript" type="text/javascript">
<!-- "hide" code in case someone is liveing in the stone age...
function validate() {
//Shorthand vars
var year = parseInt(document.forms["verification"]["year"].value);
var month = parseInt(document.forms["verification"]["month"].value) - 1;
var day = parseInt(document.forms["verification"]["day"].value);
//Date stuff
var date1 = new Date((year + 18), month, day); //Change 18 to the min age
var now = new Date;
//Are they old enough?
if ( (today.getTime() - theirDate.getTime()) < 0) {
//*boot* too younge, kiddo!
document.location="http://www.google.com";
} else {
//They are old enough, but is the email there? (not advanced checking)
if ( document.forms["verification"]["email"] == "" ) {
//No email!
alert("You forgot to enter your email.");
} else {
//All seems OK...
document.location="http://www.xxx.xxx/xxx.xxx"; //move to the welcome page
}
}
}
-->
</script>
<p>Please enter your age and email:</p>
<form name="verification" method="post" onsubmit="validate()" action="">
<p>Month:
<select name="month">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select><br />
Day:
<select name="day">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select><br />
Year:
<input type="text" name="year" size="4" maxlength="4" /></p>
<input type="checkbox" name="remember" value="1" checked />
<small>Don't ask me again</small><br />
<input type="text" name="email" size="35" maxlength="35" /><br />
<input type="submit" name="submit" value="Verify" />
</form>

Chozin
07-05-2006, 12:48 AM
ok thanks Lordrea
I will try this script thanks again and happy fourth of july

Lordrea
07-05-2006, 12:57 AM
No problem, and good luck.

Chozin
07-05-2006, 09:47 AM
no go all it does now is refresh the webpage and I have an caution icon done with errors thanks any way if you get it working let me know and again thanks

Chozin
07-05-2006, 10:29 AM
ok how about this:
you have to have the month, day and year correct to date to verify age 18 or older that part should work and even though the email is bogus (doesn't really verify that it's a real email address), they have to fill it out before they can go.
so if ther b-date say's there 18 and older if they don't fill in the email address it becomes return= false & it pop's up and say's email address required

if ther b-date say's there under 18 if they do fill in the email address it becomes return= false & it pop's up and say's your not old enough and redirect them to the non adult site (& (would be cool it also had there ip address and stated that there ip address has been detain for future refference (not a must though))

if ther b-date say's there 18 and older if they do fill in the email address it becomes return= true & goes to my web page

what would be cool is in the var over_18 = confirm('You are about to view adult sexlife, which includes some products ' +
'intended for adults. You must be 18 or 21 years old (depending on your location) to ' +
'view the site. Click OK to indicate you are of legal age, and are not offended by ' +
'adult products. To be redirected to Kids life, our general site, click Cancel.');
it also had there ip address and stated that there ip address has been detain for future refference to trick them to be scared if they are lying lol
ok well that's all i got thanks in advance.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum