Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24543 > unrolled thread
| Started by | srilatha Palla <srilatha.palla39@gmail.com> |
|---|---|
| First post | 2013-06-30 22:29 -0700 |
| Last post | 2013-10-02 20:46 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
javascript validations srilatha Palla <srilatha.palla39@gmail.com> - 2013-06-30 22:29 -0700
Re: javascript validations srilatha Palla <srilatha.palla39@gmail.com> - 2013-06-30 22:44 -0700
Re: javascript validations Joerg Meier <joergmmeier@arcor.de> - 2013-07-01 11:56 +0200
Re: javascript validations teamideyatech@gmail.com - 2013-10-02 20:46 -0700
| From | srilatha Palla <srilatha.palla39@gmail.com> |
|---|---|
| Date | 2013-06-30 22:29 -0700 |
| Subject | javascript validations |
| Message-ID | <2505673b-0065-4c5c-8d5c-0e64d60022e9@googlegroups.com> |
<%@ page import="da.ma.volks.Connector" %>
<%@page import="java.sql.*"%>
<%@ page import="java.awt.*" %>
<%@ 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 language="javascript" src="mail.js"></script>
<script type="text/javascript">
function verify()
{
var letters = /^[A-Za-z]+$/;
for( var i=0;i<document.getElementById("Registration").value.length;i++)
{
if (document.Registration.fname.value == ""
|| document.Registration.fname.value == null) {
alert(" firstname cannot be blank");
document.Registration.fname.focus();
return false;
}
else
if (!document.Registration.fname.value.match(letters)) {
alert(" Enter alphabetics only in fname");
document.Registration.fname.focus();
return false;
}
else
if (document.Registration.lname.value == ""
|| document.Registration.lname.value == null) {
alert("LastName cannot be blank ");
document.Registration.lname.focus();
return verifyfname();
}
if (!document.Registration.lname.value.match(letters)) {
alert(" Enter alphabetics only");
document.Registration.lname.focus();
return false;
}
if (document.Registration.uid.value == "") {
alert("userid cannot be blank");
document.Registration.uid.focus();
return false;
}
var letter = "_";
if (document.Registration.uid.value.match(letter)) {
alert("underscores not allowed");
document.Registration.uid.focus();
return false;
}
if (document.Registration.pwd.value == "") {
alert("password cannot be blank");
document.Registration.pwd.focus();
return false;
}
if (document.Registration.pwd.value.length < 5) {
alert("Password must be more than 5 characters");
document.Registration.pwd.focus();
return false;
}
if (document.Registration.cfmpwd.value == "") {
alert("confirmpassword cannot be blank");
document.Registration.cfmpwd.focus();
return false;
}
if (document.Registration.cfmpwd.value.length < 5) {
alert(" confirmpassword should be more than 5 characters");
document.Registration.cfmpwd.focus();
return false;
}
if ((document.Registration.pwd.value) != (document.Registration.cfmpwd.value)) {
alert("Your password does not match");
document.Registration.cfmpwd.value == "";
document.Registration.cfmpwd.focus();
return false;
}
if (document.Registration.country.value == "") {
alert(" country cannot be blank");
document.Registration.country.focus();
return false;
}
if (document.Registration.mobile.value == "") {
alert("Mobilenumber cannot be blank");
document.Registration.mobile.focus();
return false;
}
var d = new Date();
var date = d.getDate();
var month = d.getMonth() + 1;
var year = d.getFullYear();
var cdate = document.Registration.birthday.value;
var cmonth = document.Registration.birthday_month.value;
var cyear = document.Registration.birthday_year.value;
if (document.Registration.birthday_month.value == "") {
alert("Mobilenumber cannot be blank");
document.Registration.birthday_month.focus();
return false;
}
if (cmonth > month && cyear > year) {
alert("Month is not valid month");
document.Registration.birthday_month.focus();
return false;
}
if (cyear > year) {
alert("Year is not valid year");
document.Registration.birthday_year.focus();
return false;
}
if (cdate > date && cmonth > month && cyear > year) {
alert(" Date is not valid date");
document.Registration.birthday.focus();
return false;
}
}
return true;
}
function getCountryCode() {
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//alert(CountryCode);
document.getElementById("CountryCode").value = xmlhttp.responseText;
}
}
var country = document.getElementById("country").value;
xmlhttp.open("GET", "getCountryCode.jsp?country=" + country, true);
xmlhttp.send();
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration Page</title>
</head>
<body bgcolor="#33CCFF" onload="document.Registration.fname.focus()">
<center>
<font face="Times New Roman,Times" size="+3">
Registration Page</font>
</center>
<div align="center">
<form name="Registration" action="Process.jsp" method="POST" >
<input type="hidden" name="expid" value="%% EXPID %%" >
<div></div>
<center><table cellspacing="2" cellpadding="4" border="0" >
<tbody >
<tr>
<td class="normalfont"><font face="calibri" size="+1">FirstName</font> </td>
<td>
<input type="text" class="formInput" name="fname" onblur="return verify(this.value,1,0)" /></td>
</tr>
<tr>
<td class="normalfont"><font face="calibri" size="+1">LastName:</font></td>
<td>
<input type="text" class="formInput" name="lname" onblur="return verify(this.value,1,0)" /></td>
</tr>
<tr>
<td ><font face="calibri" size="+1">Preferred UserId</font></td>
<td>
<input type="text" class="formInput" name="uid" /></td>
</tr>
<tr>
<td ><font face="calibri" size="+1">Password</font></td>
<td>
<input type="password" class="formInput" name="pwd" /></td>
</tr>
<tr>
<td class="normalfont"><font face="calibri" size="+1">Confirm Password</font></td>
<td>
<input type="password" class="formInput" name="cfmpwd" /></td>
</tr>
<tr>
<td class="normalfont"><font face="calibri" size="+1">Country</font></td>
<td>
<select name="country" id="country" onchange="getCountryCode()" >
<option>- - Select Country - - </option>
<%
Connection conn =Connector.getCon();
PreparedStatement psmt = conn.prepareStatement("select COUNTRY from ISDCODE where status='Active'");
ResultSet rs = psmt.executeQuery();
while(rs.next())
{
String country = rs.getString(1);
%>
<option value="<%=country%>"><%=country %></option>
<%}
%>
</select>
</tr>
<tr>
<td class="normalfont"><font face="calibri" size="+1">Email</font></td>
<td>
<input type="text" class="formInput" name="email" onblur="return (ValidateForm());" /></td>
</tr>
<tr>
[toc] | [next] | [standalone]
| From | srilatha Palla <srilatha.palla39@gmail.com> |
|---|---|
| Date | 2013-06-30 22:44 -0700 |
| Message-ID | <29192858-655d-4e61-bc35-b1b4f7ce688a@googlegroups.com> |
| In reply to | #24543 |
On Monday, July 1, 2013 10:59:48 AM UTC+5:30, srilatha Palla wrote:
> <%@ page import="da.ma.volks.Connector" %>
>
> <%@page import="java.sql.*"%>
>
> <%@ page import="java.awt.*" %>
>
> <%@ 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 language="javascript" src="mail.js"></script>
>
>
>
> <script type="text/javascript">
>
>
>
> function verify()
>
> {
>
>
>
>
>
> var letters = /^[A-Za-z]+$/;
>
> for( var i=0;i<document.getElementById("Registration").value.length;i++)
>
> {
>
> if (document.Registration.fname.value == ""
>
> || document.Registration.fname.value == null) {
>
> alert(" firstname cannot be blank");
>
> document.Registration.fname.focus();
>
>
>
> return false;
>
> }
>
> else
>
> if (!document.Registration.fname.value.match(letters)) {
>
> alert(" Enter alphabetics only in fname");
>
> document.Registration.fname.focus();
>
> return false;
>
> }
>
> else
>
> if (document.Registration.lname.value == ""
>
> || document.Registration.lname.value == null) {
>
> alert("LastName cannot be blank ");
>
> document.Registration.lname.focus();
>
> return verifyfname();
>
> }
>
>
>
> if (!document.Registration.lname.value.match(letters)) {
>
> alert(" Enter alphabetics only");
>
> document.Registration.lname.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.uid.value == "") {
>
> alert("userid cannot be blank");
>
> document.Registration.uid.focus();
>
> return false;
>
> }
>
> var letter = "_";
>
> if (document.Registration.uid.value.match(letter)) {
>
> alert("underscores not allowed");
>
> document.Registration.uid.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.pwd.value == "") {
>
> alert("password cannot be blank");
>
> document.Registration.pwd.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.pwd.value.length < 5) {
>
> alert("Password must be more than 5 characters");
>
> document.Registration.pwd.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.cfmpwd.value == "") {
>
> alert("confirmpassword cannot be blank");
>
> document.Registration.cfmpwd.focus();
>
> return false;
>
> }
>
> if (document.Registration.cfmpwd.value.length < 5) {
>
> alert(" confirmpassword should be more than 5 characters");
>
> document.Registration.cfmpwd.focus();
>
> return false;
>
> }
>
>
>
> if ((document.Registration.pwd.value) != (document.Registration.cfmpwd.value)) {
>
> alert("Your password does not match");
>
> document.Registration.cfmpwd.value == "";
>
> document.Registration.cfmpwd.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.country.value == "") {
>
> alert(" country cannot be blank");
>
> document.Registration.country.focus();
>
> return false;
>
> }
>
>
>
> if (document.Registration.mobile.value == "") {
>
> alert("Mobilenumber cannot be blank");
>
> document.Registration.mobile.focus();
>
> return false;
>
> }
>
>
>
> var d = new Date();
>
> var date = d.getDate();
>
> var month = d.getMonth() + 1;
>
> var year = d.getFullYear();
>
>
>
> var cdate = document.Registration.birthday.value;
>
> var cmonth = document.Registration.birthday_month.value;
>
> var cyear = document.Registration.birthday_year.value;
>
> if (document.Registration.birthday_month.value == "") {
>
> alert("Mobilenumber cannot be blank");
>
> document.Registration.birthday_month.focus();
>
> return false;
>
> }
>
>
>
> if (cmonth > month && cyear > year) {
>
> alert("Month is not valid month");
>
> document.Registration.birthday_month.focus();
>
> return false;
>
> }
>
> if (cyear > year) {
>
> alert("Year is not valid year");
>
> document.Registration.birthday_year.focus();
>
> return false;
>
> }
>
> if (cdate > date && cmonth > month && cyear > year) {
>
> alert(" Date is not valid date");
>
> document.Registration.birthday.focus();
>
> return false;
>
> }
>
> }
>
> return true;
>
> }
>
>
>
> function getCountryCode() {
>
> var xmlhttp;
>
> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
>
> xmlhttp = new XMLHttpRequest();
>
> } else {// code for IE6, IE5
>
> xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
>
> }
>
> xmlhttp.onreadystatechange = function() {
>
> if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
>
> //alert(CountryCode);
>
> document.getElementById("CountryCode").value = xmlhttp.responseText;
>
> }
>
> }
>
> var country = document.getElementById("country").value;
>
> xmlhttp.open("GET", "getCountryCode.jsp?country=" + country, true);
>
> xmlhttp.send();
>
> }
>
> </script>
>
>
>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
>
> <title>Registration Page</title>
>
>
>
> </head>
>
> <body bgcolor="#33CCFF" onload="document.Registration.fname.focus()">
>
>
>
> <center>
>
> <font face="Times New Roman,Times" size="+3">
>
> Registration Page</font>
>
> </center>
>
>
>
> <div align="center">
>
> <form name="Registration" action="Process.jsp" method="POST" >
>
> <input type="hidden" name="expid" value="%% EXPID %%" >
>
> <div></div>
>
> <center><table cellspacing="2" cellpadding="4" border="0" >
>
> <tbody >
>
> <tr>
>
> <td class="normalfont"><font face="calibri" size="+1">FirstName</font> </td>
>
> <td>
>
> <input type="text" class="formInput" name="fname" onblur="return verify(this.value,1,0)" /></td>
>
>
>
> </tr>
>
> <tr>
>
> <td class="normalfont"><font face="calibri" size="+1">LastName:</font></td>
>
> <td>
>
> <input type="text" class="formInput" name="lname" onblur="return verify(this.value,1,0)" /></td>
>
> </tr>
>
> <tr>
>
> <td ><font face="calibri" size="+1">Preferred UserId</font></td>
>
> <td>
>
> <input type="text" class="formInput" name="uid" /></td>
>
> </tr>
>
> <tr>
>
> <td ><font face="calibri" size="+1">Password</font></td>
>
> <td>
>
> <input type="password" class="formInput" name="pwd" /></td>
>
> </tr>
>
> <tr>
>
> <td class="normalfont"><font face="calibri" size="+1">Confirm Password</font></td>
>
> <td>
>
> <input type="password" class="formInput" name="cfmpwd" /></td>
>
> </tr>
>
>
>
> <tr>
>
> <td class="normalfont"><font face="calibri" size="+1">Country</font></td>
>
> <td>
>
> <select name="country" id="country" onchange="getCountryCode()" >
>
> <option>- - Select Country - - </option>
>
> <%
>
> Connection conn =Connector.getCon();
>
> PreparedStatement psmt = conn.prepareStatement("select COUNTRY from ISDCODE where status='Active'");
>
> ResultSet rs = psmt.executeQuery();
>
> while(rs.next())
>
> {
>
> String country = rs.getString(1);
>
> %>
>
> <option value="<%=country%>"><%=country %></option>
>
>
>
> <%}
>
>
>
> %>
>
> </select>
>
> </tr>
>
> <tr>
>
> <td class="normalfont"><font face="calibri" size="+1">Email</font></td>
>
> <td>
>
> <input type="text" class="formInput" name="email" onblur="return (ValidateForm());" /></td>
>
> </tr>
>
> <tr>
Here is my code.i m getting alert messages continously without inserting data in the field .this is bcz i kept blur on each field and calling validation error method....can anyone suggest any other alternative...i need the field by field validation i.e.,if firstname left empty i should generate an error at runtime on beside of that textbox.....like google+ reg page...can anyone pls send the code for two fields n how to cal error message......................
I m new to java .please anyone resolve my issue...
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2013-07-01 11:56 +0200 |
| Message-ID | <1aio8e64negvt.1tqixxk0sfpc9.dlg@40tude.net> |
| In reply to | #24543 |
On Sun, 30 Jun 2013 22:29:48 -0700 (PDT), srilatha Palla wrote: > <script language="javascript" src="mail.js"></script> You are in .java, not .javascript. Despite the misleadingly similar name, Java has no more to do with Javascrip than Tigers have with Tigerlillys. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | teamideyatech@gmail.com |
|---|---|
| Date | 2013-10-02 20:46 -0700 |
| Message-ID | <c4a6f9e5-ecb6-4d6e-9880-c8a3c866a57d@googlegroups.com> |
| In reply to | #24543 |
Hi! We have an article about Javascript in our blog. You may want to check it out, it might help http://www.ideyatech.com/2013/10/javascript-programming-with-html5-data-attributes/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web