I want to connect to a database depending on the data enter in a .jsp form. I do not know how to connect to database in a Javascript.
My code as follows:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<html>
<head>
<script>
function validateForm()
{
if(document.frm.username.value=="srinu")
{
// conect database here
}
else
{
alert("wrong input");
document.frm.pwd.focus();
return false;
}
}
Body here, i want to connect database based on the details entered in the body.
<body>
<form name="frm" method="get" action="validateInput.jsp" onSubmit="return validateForm()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%"> </td>
<td width="78%"> </td>
</tr>
<tr>
<td>UserName </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>