473,388 Members | 1,346 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,388 software developers and data experts.

problems with dynamic forms

I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.

I'm not getting an error which has made it difficult to debug the code,
but I am getting the alert ("break 4 in getStyleObject"); which makes
me think this is a browser compatability issue (I'm running IE 6.0).
Anyway, the code follows
function getStyleObject (objectId) {
alert ("begin getSyleObject");
if (document.getElementById && document.getElementById(objectId)) {
alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId)) {
alert ("break 2 in getStyleObject");
return document.all(objectId).style;
}
else if (document.layers && document.layers[objectId]) {
alert ("break 3 in getStyleObject");
return document.layers[objectId];
}
else {
alert ("break 4 in getStyleObject");
return false;
}
alert ("end getSyleObject");
}
function suspendSpouse(objectId) {
alert ("begin suspendSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in suspendSpouse");
if (styleObject) {
styleObject.visibility = "hidden";
alert ("break 2 in suspendSpouse");
return true;
}
else {
alert ("break 3 in suspendSpouse");
return false;
}
alert ("end suspendSpouse");
}

function resumeSpouse (objectId) {
alert ("check yes");
alert ("begin resumeSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in resumeSpouse");
if (styleObject) {
styleObject.visibility = "visible";
return true;
}
else {
return false;
}
alert ("end suspendSpouse");
}
and the significant part of the form follows
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse(spouseLayer);">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse(spouseLayer);">
No
</td>
</tr>
<div id="spouseLayer" style="position:relative; ">
<tr>
<td class="question">Spouse's First Name:</td>
<td><input type="text" name="Spouse_First_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Last Name:</td>
<td><input type="text" name="Spouse_Last_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Contact Email</td>
<td><input type="text" name="Spouse_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">Spouse will require a vegetarian meal:</td>
<td><input type="radio" name="Spouse_meal_veggie" value="Yes">
Yes
<input type="radio" name="Spouse_meal_veggie" value="No">
No
</td>
</tr>
</div>

Jul 23 '05 #1
11 2117
BMR
I'm just having problems with IE style property ;-) It works fine with
Firefox. Which has a good debugger, you should try it to find out
where's the problem.
Anyway it's "document.all[objectId]" with brackets. But your problem is
not there. Are you sure about objectId ? Or does it exist while you call
getStyleObject() ?

BMR

br**********@wpafb.af.mil a écrit :
I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.

I'm not getting an error which has made it difficult to debug the code,
but I am getting the alert ("break 4 in getStyleObject"); which makes
me think this is a browser compatability issue (I'm running IE 6.0).
Anyway, the code follows
function getStyleObject (objectId) {
alert ("begin getSyleObject");
if (document.getElementById && document.getElementById(objectId)) {
alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId)) {
alert ("break 2 in getStyleObject");
return document.all(objectId).style;
}
else if (document.layers && document.layers[objectId]) {
alert ("break 3 in getStyleObject");
return document.layers[objectId];
}
else {
alert ("break 4 in getStyleObject");
return false;
}
alert ("end getSyleObject");
}
function suspendSpouse(objectId) {
alert ("begin suspendSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in suspendSpouse");
if (styleObject) {
styleObject.visibility = "hidden";
alert ("break 2 in suspendSpouse");
return true;
}
else {
alert ("break 3 in suspendSpouse");
return false;
}
alert ("end suspendSpouse");
}

function resumeSpouse (objectId) {
alert ("check yes");
alert ("begin resumeSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in resumeSpouse");
if (styleObject) {
styleObject.visibility = "visible";
return true;
}
else {
return false;
}
alert ("end suspendSpouse");
}
and the significant part of the form follows
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse(spouseLayer);">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse(spouseLayer);">
No
</td>
</tr>
<div id="spouseLayer" style="position:relative; ">
<tr>
<td class="question">Spouse's First Name:</td>
<td><input type="text" name="Spouse_First_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Last Name:</td>
<td><input type="text" name="Spouse_Last_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Contact Email</td>
<td><input type="text" name="Spouse_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">Spouse will require a vegetarian meal:</td>
<td><input type="radio" name="Spouse_meal_veggie" value="Yes">
Yes
<input type="radio" name="Spouse_meal_veggie" value="No">
No
</td>
</tr>
</div>

Jul 23 '05 #2
Lee
br**********@wpafb.af.mil said:

I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.

I'm not getting an error which has made it difficult to debug the code,
but I am getting the alert ("break 4 in getStyleObject"); which makes
me think this is a browser compatability issue (I'm running IE 6.0).
Anyway, the code follows
Your code would be MUCH easier to read if you used any of
the standard indentation schemes.

function getStyleObject (objectId) { onClick="resumeSpouse(spouseLayer);">


Your code is expecting an objectId that can be passed to
getElementById, but you're passing a global reference to the div,
instead. Put single quotes around 'spouseLayer' (in both onclick
handlers).

Jul 23 '05 #3
I took your advice and ran it in Firefox. I got the error "spouseLayer
is not defined".
That doesn't shed much light on the problem. spouseLayer is defined as
the name of the div.

Jul 23 '05 #4
br**********@wpafb.af.mil wrote:
I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.
[snip]

<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse(spouseLayer);">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse(spouseLayer);">

....
onClick="resumeSpouse('spouseLayer');">Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse('spouseLayer');">
....

The function is expecting a String, no?
Mick
Jul 23 '05 #5
On 24 Jan 2005 10:50:34 -0800, <br**********@wpafb.af.mil> wrote:
spouseLayer is defined as the name of the div.


That doesn't "define" anything. See
<URL:http://jibbering.com/faq/#FAQ4_41>. Besides, even if passing an
object reference via that approach does work, it's not what the function
expects (as others have pointed out).

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6
thanks, I missed that
but now that I made that change, it still won't make the layer
disappear

Jul 23 '05 #7
Lee
br**********@wpafb.af.mil said:

I took your advice and ran it in Firefox. I got the error "spouseLayer
is not defined".
That doesn't shed much light on the problem. spouseLayer is defined as
the name of the div.


Making "spouseLayer" the id attribute of an element doesn't define a
variable by that name.

Jul 23 '05 #8
Okay, but I cleaned up my code a little bit and am still having trouble
I guess I'm missing something really basic
Anyway, here's the current code
function suspendSpouse(objectId) {
var styleObject = document.getElementById(objectId).style;
if (styleObject) {
styleObject.visibility = "hidden";
return true;
}
else {
return false;
}
}

function resumeSpouse (objectId) {
var styleObject = document.getElementById(objectId).style;
if (styleObject) {
styleObject.visibility = "visible";
return true;
}
else {
return false;
}
}
..
..
..
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse('spouseLayer');">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse('spouseLayer');">
No
</td>
</tr>

Jul 23 '05 #9
Lee
br**********@wpafb.af.mil said:

Okay, but I cleaned up my code a little bit and am still having trouble
I guess I'm missing something really basic

The following works in IE and Firefox.
I didn't change the script significantly.
Since you were discarding the returned values, I removed them,
and I formatted the code so that I can read it.

My guess is that there's a problem with your HTML.
<html>
<head>
<script type="text/javascript">
function suspendSpouse(objectId) {
var styleObject = document.getElementById(objectId).style;
if (styleObject) {
styleObject.visibility = "hidden";
}
}

function resumeSpouse (objectId) {
var styleObject = document.getElementById(objectId).style;
if (styleObject) {
styleObject.visibility = "visible";
}
}
</script>
</head>
<body>
<form>
Check if Spouse will come:
<br>
<input type="radio"
name="Spouse_Attend"
value="Yes"
checked="checked"
onclick="resumeSpouse('spouseLayer');"> Yes
<br>
<input type="radio"
name="Spouse_Attend"
value="No"
onclick="suspendSpouse('spouseLayer');"> No
<br>
<div id="spouseLayer">SpouseLayer</div>
</form>
</body>
</html>

Jul 23 '05 #10
I used your script and the page still didn't work as hoped. So, I must
have a problem with my html.
I know I've already taken a great deal of your time, but if you don't
mind, I really need some help here.
My complete page is, now, as follows

<%@ Language=VBScript %>
<% Option Explicit %>

<!--#include file = "DatabaseConnect.asp"-->
<!--#include file = "adovbs.inc"-->

<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Air Force Material Command Squadron Commanders' and Directors'
Course Registration Page </title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
body {
background: blue;
}
table {
width: 95%;
border: "0";
align: "center";
}
img {
width: "128";
height: "128";
align: "center";
}
h1 {
font-size: 24px;
font-weight: bold;
}
h2 {
font-size: 18px;
}
p {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
}
hr {
width: "100%";
size: = "1";
noshade;
}
td.question {
width: "279";
align: "right";
}
td.ContactInfo {
font-color:"white";
font-size:+1;
}
td.linebreak {
colspan: "2";
}

</style>
<script type="text/javascript" language="javascript">
function DisplayErrors() {
if (document.enroll.coursedate.value=="") alert ("Please enter a
coursedate");
if (document.enroll.rank.value=="") alert ("Please enter a rank");
if ((isValidName(document.enroll.firstname.value))==f alse) alert
("Please enter your first name");
if ((isValidName(document.enroll.middleinitial.value) )==false) alert
("Please enter your middle initial");
if ((isValidName(document.enroll.lastname.value))==fa lse) alert
("Please enter your last name");
if ((isValidDate(document.enroll.dateRank.value))==fa lse) alert
("Please enter valid date of rank in form mm/dd/yyyy");
if (document.enroll.projected_unit.value=="") alert ("Please enter
your projected unit");
if (document.enroll.projected_base.value=="") alert ("Please enter
your projected base");
if (isValidPhone(document.enroll.projected_phone.valu e)==false)
alert ("Please enter a valid projected phone number in the form
xxx-xxx-xxxx");
if (isValidDate(document.enroll.Change_com_date.value )==false) alert
("Please enter a valid date for the change of command in the form
mm/dd/yyyy");
if (isValidEmail(document.enroll.Current_email.value) ==false) alert
("Please enter your current email address");
if (isValidEmail(document.enroll.Transit_Email.value) ==false) alert
("Please enter a valid transit email");
} // end DisplayErrors function

function ValidateForm()
{
alert ("form validation started");
var passCheck = false;
if ((document.enroll.coursedate.value!=="") &&
(document.enroll.rank.value!=="") &&
(document.enroll.firstname.value!=="") &&
(document.enroll.lastname.value!=="") &&
(isValidDate(document.enroll.rankdate.value)!==fal se) &&
(document.enroll.projected_unit.value!=="") &&
(document.enroll.projected_base.value!=="") &&
(isValidPhone(document.enroll.projected_phone.valu e)!==false) &&
(isValidDate(document.enroll.change_com_date.value )!==false) &&
(isValidEmail(document.enroll.current_email.value) !== false) &&
(isValidEmail(document.enroll.Transit_Email.value) !==false) &&
(isValidPhone(document.enroll.Transit_Phone.value) !==false) &&
(document.enroll.Current_Base.value!=="") &&
(document.enroll.Current_Unit.value!=="") &&
(isValidPhone(document.enroll.Current_DSN.value)!= =false) &&
(document.enroll.Spouse_First_Name.value!=="") &&
(document.enroll.Spouse_Last_Name.value!=="") &&
(isValidEmail(document.enroll.Spouse_Email)!==fals e))
{
passCheck = true;
}
if (passCheck==false) DisplayErrors();
return passCheck;
} // end isFormValid function

function isValidDate (testDate) {
var invalidDate = true;
//alert ("isValidDate break 1");
if (testDate.length!==8)
{
alert ("date is not of expected length");
return false;
}
datePart = testDate.slice(0,1);
if (cint(datePart) < 1) OR (cint(datePart) > 12)
{
alert ("month is not in expected range");
return false;
}
datePart = testDate.slice (2,3);
if (cint(datePart < 1)) OR (cint(datePart) > 12)
{
alert ("day is not in expected range");
return false;
}
datePart = testDate.slice (4,7);
if (cint(datePart) < 1950) OR (cint(datePart) > 2050)
{
alert ("year is not in expected range");
return false;
}
return true;
} // end isValidDate function

function isValidName (testName) {
var myRegExp = /[A-Z][a-z]{1,29}/;
//alert (myRegExp.test(testName));
return myRegExp.test(testName);
} // end isValidName function

function isValidPhone (testPhone) {
var myRegExp = /[1-9][0-9]{2}-[0-9]{4}/;
return myRegExp.test(testPhone);

} // end isValidPhone function

function isValidEmail (testEmail) {
var myRegExp =
/[a-z0-9.]{1,40}@[a-z0-9.]{4,65}.(com|net|org|info|biz|([a-z]{2,3}.[a-z]{2}))/;
return myRegExp.test(testEmail)
} // end isValidEmail function

function getStyleObject (objectId) {
//alert ("begin getSyleObject");
//if (document.getElementById && document.getElementById(objectId))
{
//alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
//}
//else if (document.all && document.all(objectId)) {
//alert ("break 2 in getStyleObject");
//return document.all(objectId).style;
//}
//else if (document.layers && document.layers[objectId]) {
//alert ("break 3 in getStyleObject");
//return document.layers[objectId];
//}
//else {
//alert ("break 4 in getStyleObject");
//return false;
//}
//alert ("end getSyleObject");
}
function suspendSpouse(objectId) {
//alert ("begin suspendSpouse");
//var styleObject = getStyleObject (objectId);
var styleObject = document.getElementById(objectId).style;
//alert ("break 1 in suspendSpouse");
if (styleObject) {
//alert ("styleObject.visibility = "+styleObject.visibility);
styleObject.visibility = "hidden";
//alert ("styleObject.visibility = "+styleObject.visibility);
//alert ("break 2 in suspendSpouse");
//return true;
}
//else {
//alert ("break 3 in suspendSpouse");
//return false;
//}
//alert ("end suspendSpouse");
}

function resumeSpouse (objectId) {
//alert ("check yes");
//alert ("begin resumeSpouse");
//var styleObject = getStyleObject (objectId);
var styleObject = document.getElementById(objectId).style;
//alert ("break 1 in resumeSpouse");
if (styleObject) {
styleObject.visibility = "visible";
//return true;
}
//else {
//return false;
//}
//alert ("end suspendSpouse");
}

</script>
</head>
<body>
<table>
<tr>
<td><img src="afmc.gif" alt="HQ AFMC shield"></td>
</tr>
<tr>
<td><h1>Air Force Materiel Command</h1></td>
</tr>
<tr>
<td><h1>Squadron Commanders' and Directors' Course</h1></td>
</tr>
<tr>
<td><h1>Registration Page</h1></td>
</tr>
<tr>
<td><p>(Use the &quot;TAB&quot; key or mouse button to move to the
next cell entry. &quot;ENTER&quot; key will submit registration
pre-maturely<p></td>
</tr>
<tr>
<td class="linebreak"><hr></td>
</tr>
<tr>
<td><h2>Attendee Information:</h2></td>
</tr>
<tr>
<td>
<form name="enroll" method="post" onsubmit="return ValidateForm()"
action="/sqccform/sqccform2.asp">
<table>
<tr>
<td class="question">Requested Course Date:</td>
<td><select name="coursedate">
<option value="">Select a Course Date
<option value="March 14-18">March 14-18
<option value="May 23-27">May 23-27
<option value="July 11-15">July 11-15
<option value="Aug 29-Sept 2">Aug 29-Sept 2
<option value="Sep 26-30">Sept 26-30
</select>
</td>
</tr>
<tr>
<td class="question">Select Rank/Civ Paygrade:</td>
<td><select name="rank">
<option value="">Select Rank/Civ Paygrade
<option value="Capt">Capt
<option value="Maj">Maj
<option value="LtCol">Lt Col
<option value="Col">Col
<option value="GS-12">GS-12
<option value="GS-13">GS-13
<option value="GS-14">GS-14
<option value="GS-15">GS-15
</select>
</td>
</tr>
<tr>
<td class="question">First Name:</td>
<td><input type="text" name="firstname" maxlength="30"></td>
</tr>
<tr>
<td class="question">Middle Initial:</td>
<td><input type="text" name="middleinitial" maxlength="1"></td>
</tr>
<tr>
<td class="question">Last Name:</td>
<td><input type="text" name="lastname" maxlength="30"></td>
</tr>
<tr>
<td class="question">Go By Name:</td>
<td><input type="text" name="gobyname" maxlength="30"></td>
</tr>
<tr>
<td class="question">Date of Rank:</td>
<td><input type="text" name="dateRank" maxlength="8"></td>
</tr>
<tr>
<td class="question">Projected Unit</td>
<td><select name="projected_unit">
<option value="">Select a Unit
<%
dim objRs
set objRs=Server.CreateObject("ADODB.Recordset")
objRs.Open "squadlist", objConn
do while NOT objRs.EOF
%>
<option
value="<%=objRs("squadname")%>"><%=objRs("squadnam e")%>
<%
objRs.MoveNext
loop
objRs.Close
set objRs = Nothing
objConn.Close
set objConn = Nothing
%>
</select>
</td>
</tr>
<tr>
<td class="question">Projected Base:</td>
<td><input type="text" name="projected_base"
maxlength="50"></td>
</tr>
<tr>
<td class="question">Projected DSN Phone:</td>
<td><input type="text" name="projected_phone"
maxlength="12"></td>
</tr>
<tr>
<td class="question">Change of Command:</td>
<td><input type="text" name="Change_com_date"
maxlength="8"></td>
</tr>
<tr>
<td class="question">Current Email Address:</td>
<td><input type="text" name="Current_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">In Transit E-mail Address:</td>
<td><input type="text" name="Transit_Email" maxlength="70"></td>
</tr>
<tr>
<td class="question">In Transit Phone Number:</td>
<td><input type="text" name="Transit_Phone" maxlength="12"></td>
</tr>
<tr>
<td class="question">Current Base:</td>
<td><select name="current_base">
</select>
</td>
</tr>
<tr>
<td class="question">Current Unit:</td>
<td><input type="text" name="current_unit" maxlength="50"></td>
</tr>
<tr>
<td class="question">Current DSN Phone:</td>
<td><input type="text" name="current_dsn" maxlength="12"></td>
</tr>
<tr>
<td class="question">Vegetarian Meal Required:</td>
<td><input type="radio" name="Primary_Veggie" value="Yes">
Yes
<input type="radio" name="Primary_Veggie" value="No">
No
</td>
</tr>
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onclick="resumeSpouse('spouseLayer');"> Yes
<input type="radio" name="Spouse_Attend" value="No"
checked="checked" onclick="suspendSpouse('spouseLayer');"> No
</td>
</tr>
<div id="spouseLayer">
<tr>
<td class="question">Spouse's First Name:</td>
<td><input type="text" name="Spouse_First_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Last Name:</td>
<td><input type="text" name="Spouse_Last_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Contact Email</td>
<td><input type="text" name="Spouse_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">Spouse will require a vegetarian meal:</td>
<td><input type="radio" name="Spouse_meal_veggie" value="Yes">
Yes
<input type="radio" name="Spouse_meal_veggie" value="No">
No
</td>
</tr>
</div>
</table>
<tr>
<td class="linebreak"><hr></td>
</tr>
<table>
<tr>
<td><input type=submit value="Submit"></td>
<td><input type="reset" value="Clear Form and Start Over"></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td class="ContactInfo">Questions? Comments? Please call Capt. Dain
Klein at DSN: 787-2125<td>
</tr>
</table>
</body>
</html>

Jul 23 '05 #11
JRS: In article <11*********************@f14g2000cwb.googlegroups. com>,
dated Tue, 25 Jan 2005 05:26:26, seen in news:comp.lang.javascript,
br**********@wpafb.af.mil posted :
<title>Air Force Material Command Squadron Commanders' and Directors'
Course Registration Page </title>
A thoughtful and internationally-sensitive author would have indicated
which Air Force is being referred to.

<style type="text/css">
Forcing the sizes of fonts and suchlike is not considered good practice.
It is possible that you do not, in your application, need to allow for
those with sub-standard vision; but 14-point for ordinary text is too
large to suit me.
p {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
}
<script type="text/javascript" language="javascript"> attribute not required
function DisplayErrors() {
if (document.enroll.coursedate.value=="") alert ("Please enter a
coursedate");
If you want your code to be readable in News, do not let your posting
agent break lines. A good craftsman chooses good tools.

if ((isValidName(document.enroll.firstname.value))==f alse) alert
("Please enter your first name");
... == false is not needed; use !... .

Does it matter that some people put family name first, or does your
organisation not allow that?

function ValidateForm()
{
alert ("form validation started");

Code should be indented to show intended structure; you have chosen a
badly-designed posting agent which damages readability. A good
craftsman chooses good tools.
(isValidEmail(document.enroll.Spouse_Email)!==fals e))

That's an interesting operator to choose.

function isValidDate (testDate) {
var invalidDate = true;
//alert ("isValidDate break 1");
if (testDate.length!==8)
{
alert ("date is not of expected length");
return false;
}
datePart = testDate.slice(0,1);
if (cint(datePart) < 1) OR (cint(datePart) > 12)
{
alert ("month is not in expected range");
return false;
}
datePart = testDate.slice (2,3);
if (cint(datePart < 1)) OR (cint(datePart) > 12)
{
alert ("day is not in expected range");
return false;
}
datePart = testDate.slice (4,7);
if (cint(datePart) < 1950) OR (cint(datePart) > 2050)
{
alert ("year is not in expected range");
return false;
}
return true;
} // end isValidDate function
Bloated; and I was going to say that it did not discriminate between
months of 28,29,30,31 days. But that pales into insignificance when one
sees that you only allow 12 days in each month.

I know what cint does in VBScript, but not of its use in javascript.

You appear to be checking an 8-digit field; but your strings call for
FFF dates, mm/dd/yyyy. Did you intend to allow a 101-year range?

Proper date validation need not be lengthy; see sig.

function isValidName (testName) {
var myRegExp = /[A-Z][a-z]{1,29}/;
//alert (myRegExp.test(testName));
return myRegExp.test(testName);
} // end isValidName function
That accepts "Ug", though it rejects "U Thant"

It accepts "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysili ogogogoch"
and also "llanfairpwllgwyngyllgogerychwyrndrobw1111antysiIi ogogogoch".
You may not have expected that. It also accepts "00000Ol111111".
It accepts ("O'Keefe") which IIRC is the name of a NASA boss; but I
suspect that's accidental.

function isValidPhone (testPhone) {
var myRegExp = /[1-9][0-9]{2}-[0-9]{4}/;
return myRegExp.test(testPhone);
Appears to require the form ddd-dddd to be somewhere in the input.
Strings call for xxx-xxx-xxxx.
} // end isValidPhone function

function isValidEmail (testEmail) {
var myRegExp =
/[a-z0-9.]{1,40}@[a-z0-9.]{4,65}.(com|net|org|info|biz|([a-z]{2,3}.[a-z]{2}))/;
return myRegExp.test(testEmail)
} // end isValidEmail function
Rejects many valid left parts. Rejects "xx*@yyy.co.uk", which is valid.
Accepts "##*@yy7y.co.uk" which may be valid but is evidently not
intended. Accepts "Joe St****@yy7y.Leonid Brezhnev") .
function getStyleObject (objectId) {
//alert ("begin getSyleObject"); ^ <G>//if (document.getElementById && document.getElementById(objectId))
{
//alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
//}
//else if (document.all && document.all(objectId)) {
//alert ("break 2 in getStyleObject");
//return document.all(objectId).style;
//}
//else if (document.layers && document.layers[objectId]) {
//alert ("break 3 in getStyleObject");
//return document.layers[objectId];
//}
//else {
//alert ("break 4 in getStyleObject");
//return false;
//}
//alert ("end getSyleObject");
}
Does that mean that your Air Force still has Netscape 4???
function suspendSpouse(objectId) {


Seems a tactless function identifier <g>.

ISTM that your Air Force should employ a programmer to do your task.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
9
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to...
3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
7
by: Martin Hazell | last post by:
I have had a form within a project that has been tested and working for the past 4-5 months. The other day, I decided to change all of my database connection strings into a dynamic property for a...
3
by: Keith Smith | last post by:
How do most people deal with different screen sizes? I was thinking about creating certain Forms that are displayed when certain screen sizes are used, but that sure does seem like an awful lot of...
7
by: AdeelAlvi | last post by:
iam working on a project called service desk that automates the departmental services online .one major component i have to create is that to convert paper based forms into dynamic webforms . i...
2
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic...
3
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
2
by: yomadhu | last post by:
I created a dynamic form in javascript. Am unable to get those values in to php to display. I need all details. If i add 10 rows the i need to display those all values. Can any one help me for that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.