473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

why javascript validation is not performed for mobile number and state in my code?

i have written a javascript code for mobile number and state validation but function is working except mobile number and state validation , where is my mistakes ?

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">

function checkForm(form)
{
if(form.email1.value != "" && form.email1.value == form.email2.value)
{

}
else
{ alert("Error: Please check that you've entered and confirmed your email id!");
form.email1.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value)
{
if(form.pwd1.value.length < 6)
{
alert("Error: Password must contain at least one characters!");
form.pwd1.focus();
return false;
}
if(form.pwd1.value == form.email.value) {
alert("Error: Password must be different from Username!");
form.pwd1.focus();
return false;
}
re = /[0-9]/;
if(!re.test(form.pwd1.value))
{
alert("Error: password must contain at least one number (0-9)!");
form.pwd1.focus();
return false;
}
re = /[a-z]/;
if(!re.test(form.pwd1.value))
{
alert("Error: password must contain at least one lowercase letter (a-z)!");
form.pwd1.focus();
return false;
}

}
else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}

if(form.mnum1.value != "" && form.mnum1.value == form.mnum2.value)
{

}
else
{ alert("Error: Please check that you've entered and confirmed your mobile number!");
form.mnum1.focus();
return false;
}
if(document.form.Country.selectedIndex=="")
{
alert ( "Please select a state!");
return false;
}

return true;
}

</script>

</head>
<body >


<form name = "form" action="./careers2.jsp" method="post" onsubmit = "return checkForm(this);">
<center><br><br>


<h2>First step Registration start</h2>
<br>
<center>
<table border="2">
<tr><td align="right">E-mail :</td> <td align="left"><input type="email" name="email1" required></td> </tr>
<tr><td align="right">Retype E-mail :</td> <td align="left"><input type="email" name="email2" required></td> </tr>
<tr><td align="right">Password :</td> <td align="left"><input type = "password" name = "pwd1" required></td></tr>

<tr><td align="right">Retype Password : </td><td align="left"><input type = "password" name = "pwd2" required></td></tr>

<!-- <tr><td align="right">Mobile Number : </td><td align="left"><input type = "tel" name = "mnum1" required></td></tr>
<tr><td align="right">Retype Mobile Number : </td><td align="left"><input type = "tel" name = "mnum2" required></td></tr>-->
<%

out.write("<tr><td align=\"right\">State :</td><td align=\"left\"> <select name=\"Country\" >"+
"<option value=\"Select\">----------Select State------------</option>"+
"<option value=\"Andaman and Nicobar Islands\">Andaman and Nicobar Islands</option>"+
"<option value=\"Andhra Pradesh\">Andhra Pradesh</option>"+
"<option value=\"Arunachal Pradesh\">Arunachal Pradesh</option>"+
"<option value=\"Assam\">Assam</option>"+
"<option value=\"Bihar\">Bihar</option>"+
"</select> </td></tr>"
);


%>
</table><br><br>
<input type = "submit" value = "Submit" class="button1"></center>

</center><br><br><br><br><br><br><br><br><br><br><br >
</form>
</body>
</html>
Jun 19 '17 #1
1 1041
chaarmann
785 Expert 512MB
You are in the wrong forum. This is Javascript
Java is not Javascript.
Jun 20 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I...
1
by: karen987 | last post by:
I have a comment form, on a news website, ASP page, which users fill in and it adds comments to a news article. The reader clicks on a headline and the comments open up in a new window. It already...
1
by: ll | last post by:
Hi, I am working with a page that has both cfform elements and 'plain html' form elements. In particular, I am needing to validate my textarea form field and my email text field. On one of my...
1
by: shrin | last post by:
Hi all, I want to use asp.net validator and javascript validation function on a single form for different fields. also I want to execute some code on button click after the validation is completed....
1
by: arasapandy | last post by:
hi i have one problem in javascript validation,i need one RegEx for mobile number,format is (91-1234567),from left to right first 2 numbers after 2 numbers hyphen after hyphen 7 numbers,this format...
1
by: jhansi | last post by:
hi... I have created a form it's working properly.... but i want to consider phone number and STD code in two different text field for a single lable phone number..... and I have considered...
4
by: karthisargunan | last post by:
Hello, I am developing the project of "Employee Information System" using C language, In this project i want to add the mobile number for the each employee {Each Mobile number having 7...
1
by: Blacky | last post by:
Hi, I need a javascript validation which checks for Same digit: 0000000000, 1111111111, 2222222222, 3333333333, 4444444444, 5555555555, 6666666666, 7777777777, 8888888888, 9999999999 ...
10
by: Jacob Clements | last post by:
Hello, I am very new to Javascript and I've only understanding for simple Javascript. I had to develop a Javascript validation form for a project. I have done so, using the most simple methods....
1
by: anantbukane | last post by:
i want to validate mobile number of 10 digits and to have decimal in basic salary amount plz send the code to validate it
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.