Search This Blog

Friday 7 January 2022

10. HTML program to read registration details & JSP program to generate OTP and check for registration.

 <!--  10. HTML program to read registration details. -->

<html>

<head>

<title>OTP Form</title>

</head>

<body bgcolor=gray text=yellow>

 

<form action="Prog10.jsp">

<table border=3>

<tr><td>Student Name:</td><td><input type=text name=sname></td></tr>

<tr><td>Email ID:</td><td><input type=text name=email></td></tr>

<tr><td>Date of Birth:</td><td><input type=text name=dob></td></tr>

</table>

<script language="JavaScript">

function check()

{

     var str1=document.forms[0].elements[2].value;

     var result = str1.substring(10, 6);

     if(result>2003)

          alert("Age should be greater than 18 years!");

     else

          alert("Click on Submit")

}

</script>

<input type=button value=Proceed onClick="check()" name=Proceed>

<input type=submit value=Submit>

<input type=Reset value=Clear>

</form>

 

</body>

</html>

<!--  10. JSP program to generate OTP and check for registration. -->

<html>

<head>

<%@page import="java.io.*,java.util.*,java.text.SimpleDateFormat"%>

<title>OTP Generation</title>

 

</head>

<body bgcolor=gray text=yellow>

Date and Time:

<%

SimpleDateFormat dt = new SimpleDateFormat("dd-MM-YYYY HH:mm:ss");

String date = dt.format(new Date());

out.println(date);

String sname=request.getParameter("sname");

String email=request.getParameter("email");

String dob=request.getParameter("dob");

//String otp=request.getParameter("otp1");

//out.println(otp);

%>

 

<table border=3>

<tr><th>StudentName:</th><th><%=sname %></th></tr>

<tr><td>Email ID:</td><td><%=email %></td></tr>

<tr><td>Date of Birth:</td><td><%=dob %></td></tr>

</table>

 

<form>

<input type=button value=GetOTP onClick="OTP()">

<input type=button value=Submit >

</form>

<script language="JavaScript">

var otp;

function OTP()

{

     var otp=Math.floor(Math.random() * 10000) + 1;

     alert(otp);

     var otp1=prompt("Enter the OTP");

     if(otp1==otp)

          document.write("<font color=green >Registration Success!</font>");

     else

          document.write("<font color=red >OTP Mismatch!</font>");

}

 </script>

</body>

</html>

No comments :

Post a Comment

FREE Hit Counters