hi
i have done a page which contains username and password,there i have to check my username and password string and authenticate that page.
here is my code.

<%@ page language="java" %>
<html>
<head>
<title> WELCOME </title>
<script language = "Javascript">


function ValidateEmail(){
	var emailID=document.frm.t1;
        var emailID1=document.frm.t2;
	
	if ((emailID.value==null)||(emailID.value==""))
{
		alert("Please Enter A Valid User Name")
		emailID.focus()
		return false
	}

	
 if ((emailID1.value==null)||(emailID1.value=="")){
		alert("Please Enter Your Password")
		emailID1.focus()
		return false
	}
	
	return true
 }
</script>
</head>
<body>
<center/><h1>SOFTWARE ENGINEER RECRUITMENT</h1>
<marquee SCROLLDELAY=250><h4> To test your Intelligence Quotient  </h4></marquee>
<body style="background-color:#F5F5DC">
<br>
<br>
<br>
<br><br>
<br><br>
<center>
<form name="frm" method="post" action="login.jsp" onSubmit="return ValidateEmail()">
<h3>USERNAME:
<input type="text" name="t1"  /> 
<br><br>
PASSWORD:
<input type="password" name="t2" />
</h3>
<br>
<input type="submit" value="Login"/>  &nbsp&nbsp&nbsp&nbsp
<input type="reset" value="clear"/>
</form>
</html>

hi
in this code i have to invoke my own username which has to be used to open the next page. i need to mention that username and password in my code...

Member Avatar for rajarajan2017
if (document.frm.t1.value==/^[a-zA-Z]+\s[a-zA-Z]+$/)
  {;return true;}
  else 
  {alert("Invalid name format.");return false;}

Feed this within the ValidateEmail() for both username and password.

Note: You should carefull about your naming convention, where do you get your email id? which is not relevant to your subject.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.