This is my Index.php::
<html>
<head><title>Registration</title>
<script type="text/javascript">
function numbersonly(e,length)
{
var unicode=e.charCode? e.charCode : e.keyCode
var maxlength=length;
if (unicode!=8)
{ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}
</script>
<script type="text/javascript">
function validation()
{
var a = document.register.phone.value;
if(a=="")
{
alert("Please Enter Your Phone Number");
document.register.phone.focus();
return false;
}
}
</script>
<script type="text/javascript">
var reg = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
function PhoneValidation(phone)
{
var OK = reg.exec(phone.value);
if (!OK)
window.alert("phone number isn't valid");
else
// window.alert("phone number is valid");
return true;
}
</script>
<script language="javascript">
function checkEmail()
{
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{3})+$/;
if (!filter.test(email.value))
{
alert('Please provide a valid email address');
email.focus;
return false;
}
}
</script>
<script>
function checkPassword()
{
var pwd = document.getElementById("password").value;
var rpwd = document.getElementById("repeatpassword").value;
if(pwd != rpwd)
{
alert("Your password does not match");
document.getElementById('<%= rpwd%>').focus();
//return false;
}
}
</script>
<script type="text/javascript">
window.onload = function () {
document.getElementById("name").focus();
};
</script>
</head>
<body>
<!--<script language="JavaScript">
alert("Hi!.")
</script>-->
<div align="center">
<h3> Registration</h3>
<form name="register" action="save.php" enctype="multipart/form-data" onSubmit="return validation()" method="post">
<label>Name</label>
<label>:</label>
<input type="text" name="name" id="name" placeholder="Name" required/><br /><br />
<label>Email</label>
<label>:</label>
<input type="email" name="email" id="email" placeholder="Email" required/><br /><br />
<label>Password</label>
<label>:</label>
<input type="password" name="password" id="password" placeholder="Password" required/><br /><br />
<label>RepeatPassword</label>
<label>:</label>
<input type="password" name="repeatpassword" id="repeatpassword" placeholder="RepeatPassword" onBlur="checkPassword()"required/><br /><br />
<label>Date of Birth</label>
<label>:</label>
<select name="day" required>
<option value="">Day</option>
<?php for ($day = 1; $day <= 31; $day++) { ?>
<option value="<?php echo strlen($day)==1 ? '0'.$day : $day; ?>"><?php echo strlen($day)==1 ? '0'.$day : $day; ?></option>
<?php } ?>
</select>
<select name="month" required>
<option value="">Month</option>
<?php for ($month = 1; $month <= 12; $month++) { ?>
<option value="<?php echo strlen($month)==1 ? '0'.$month : $month; ?>"><?php echo strlen($month)==1 ? '0'.$month : $month; ?></option>
<?php } ?>
</select>
<select name="year" required>
<option value="">Year</option>
<?php for ($year = date('Y'); $year > date('Y')-100; $year--) { ?>
<option value="<?php echo $year; ?>"><?php echo $year; ?></option>
<?php } ?>
</select>
<br /><br /><!--<input type="date" id="date" name="date" required><br /><br />-->
<label>Phone</label>
<label>:</label>
<input type="text" name="phone" id="phone" placeholder="Phone No" maxlength="10" onKeyPress="return numbersonly(event)" onChange="PhoneValidation(this);" required/><br /><br />
<input type="submit" name="submit" value="Register" onClick="return checkEmail()"/>
</form>
</div>
</body>
</html>
if the password field, and password field are not same , it will alert a box like: your password doesnot match." but the cursor does not focus on the repeat password fieldm it moves to next field, how to focus that repeat password field, what i have to change in my code.
AntonyRayan
15
Posting Whiz in Training
Recommended Answers
Jump to Post
document.getElementById('<%= rpwd%>').focus();
Why not just put "repeatpassword" there like you did on other occasions.
Also, you don't need a
<script>
block for every function. If you want to generate that part of the page you can put them in external files.
All 4 Replies
Traevel
216
Light Poster
AntonyRayan
15
Posting Whiz in Training
lorenzoDAlipio
24
Junior Poster in Training
AntonyRayan
15
Posting Whiz in Training
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.