Wednesday, 27 March 2019

Code

<html>
<head>
<title>Implimentation</title>
<script type="text/javascript">

function myFunction() {
var fname = document.getElementById("fname").value;
var lname = document.getElementById("lname").value;
var email = document.getElementById("email").value;
var remail = document.getElementById("remail").value;
var password = document.getElementById("password").value;

  //  http://www.randomsnippets.com/2008/04/01/how-to-verify-email-format-via-javascript/

var status = false;   
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;


  var x = document.getElementById("male").checked;
  var y = document.getElementById("female").checked;

  var year1 = document.getElementById("year").value;
  var month1 = document.getElementById("month").value;
  var day1 = document.getElementById("day").value;



if(fname=="")
{
alert("Please Enter First Name");
}

else if(lname=="")
{
alert("Please Enter Last Name");
}
else if(email=="")
{
alert("Please Enter Email");
}
else if (document.myform.email.value.search(emailRegEx) == -1)

          alert("Please enter a valid email address.");
      }
else if(remail=="")
{
alert("Please Enter Re-enter Email");
}

else if(email != remail)
{
alert("Please Check Email");
}
else if(password=="")
{
alert("Please Enter Password");
}
else if (password.length<8) {
alert("Please enter 8 digit password");
}
  else if(day1==0)
  {
  alert("Please select Day")
  }
  else if(month1==0)
  {
  alert("Please select Month")
  }
  else if(year1==0)
  {
  alert("Please select year")
  }
  else if(year1>2003)
  {
  alert("You are not eligible. Age should be above 16...!!!")
  }

else if(x!=true && y!=true)
  {
  alert("gender");
  }
  else
  {

  alert("Name = " + fname + "\n" + "Last Name = " + lname
  + "\n" + "Email = " + email
  + "\n" + "Password = " + password
  + "\n" + "DOB = " + day1 + "-" + month1 + "-" + year1
  );
  }

}

</script>
</head>

<body>

<form name="myform">
<h1>User Registration Form</h1>
<input type="text" placeholder="First Name" id="fname">
<input type="text" placeholder="Last Name" id="lname"><br><br>
<input type="text"  name="email" placeholder="Email" id="email"><br><br>
<input type="text" placeholder="Re-enter Email" id="remail"><br><br>
<input type="password" placeholder="Enter Password" id="password"><br><br>

Birthdate : <br>
<select id="day">
  <option value="0">day</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
  <option value="10">10</option>
  <option value="11">11</option> 
  <option value="12">12</option>
  <option value="13">13</option>
  <option value="14">14</option>
  <option value="15">15</option>
  <option value="16">16</option>
  <option value="17">17</option>
  <option value="18">18</option>
  <option value="19">19</option>
  <option value="20">20</option>
  <option value="21">21</option>
  <option value="22">22</option>
  <option value="23">23</option> 
  <option value="24">24</option>
  <option value="25">25</option>
  <option value="26">26</option>
  <option value="27">27</option>
  <option value="28">28</option>
  <option value="29">29</option>
  <option value="30">30</option>
  <option value="31">31</option>
</select>


<select id="month">
  <option value="0">Month</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
  <option value="10">10</option>
  <option value="11">11</option> 
  <option value="12">12</option>
</select>


<select id="year">
  <option value="0">Year</option>
  <option value="1996">1996</option>
  <option value="1997">1997</option>
  <option value="1998">1998</option>
  <option value="1999">1999</option>
  <option value="2000">2000</option>
  <option value="2001">2001</option>
  <option value="2002">2002</option>
  <option value="2003">2003</option>
  <option value="2004">2004</option>
  <option value="2005">2005</option>
  <option value="2006">2006</option>
  <option value="2007">2007</option>
  <option value="2008">2008</option>
  <option value="2009">2009</option>
  <option value="2010">2010</option>
  <option value="2011">2011</option>
  <option value="2012">2012</option>
  <option value="2013">2013</option>
  <option value="2014">2014</option>
  <option value="2015">2015</option>
  <option value="2016">2016</option>
  <option value="2017">2017</option>
  <option value="2018">2018</option>
  <option value="2019">2019</option>
</select>

<br><br>
  <input type="radio" name="gender" id="male" value="male"> Male
  <input type="radio" name="gender" id="female" value="female"> Female<br>

<button type="button" onclick="myFunction()">SignUp</button>

</form>
</body>
</html>

No comments:

Post a Comment

Code

<html> <head> <title>Implimentation</title> <script type="text/javascript"> fu...