Last active
September 22, 2020 09:20
-
-
Save pulkitnehra/995620fd2da8140a757bd1b9a0495507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | |
pageEncoding="ISO-8859-1"%> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="ISO-8859-1"> | |
<title>Create a new user</title> | |
</head> | |
<body> | |
<jsp:directive.include file="header.jsp"/> | |
<div align="center"> | |
<br><br> | |
<h2>Create New User</h2> | |
</div> | |
<div align="center"> | |
<form action="create_user" method="post" onsubmit=" return validateFormInput()"> | |
<table> | |
<tr> | |
<td align="right">Email:</td> | |
<td align="left"><input type="text" id="email" name="email" size=20 ></td> | |
</tr> | |
<tr> | |
<td align="right">Full Name:</td> | |
<td align="left"><input type="text" id=fullname name="fullname" size=20></td> | |
</tr> | |
<tr> | |
<td align="right">Password:</td> | |
<td align="left"><input type="password" id=password name="password" size=20></td> | |
</tr> | |
<tr><td> </td></tr> | |
<tr > | |
<td colspan="2" align="center"> | |
<input type="submit" value="Save"> | |
<input type="button" value="cancel" onclick="javascript:history.go(-1)"> | |
</td> | |
</tr> | |
</table> | |
</form> | |
</div> | |
<jsp:directive.include file="footer.jsp"/> | |
</body> | |
<script type="text/javascript"> | |
function validateFormInput() { | |
var fieldEmail = document.getElementByID("email"); | |
var fieldFullName = document.getElementByID("fullname"); | |
var fieldPassword = document.getElementByID("password"); | |
if(fieldEmail.value.length==0){ | |
alert("Email is required!"); | |
fieldEmail.focus(); | |
return false; | |
} | |
if(fieldPassword.value.length==0){ | |
alert("Password is required!"); | |
fieldPassword.focus(); | |
return false; | |
} | |
if(fieldFullName.value.length==0){ | |
alert("Full Name is required!"); | |
fieldFullName.focus(); | |
return false; | |
} | |
return true; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem in validating Javascript