[Object] Printing for no reason and won't tab

wxdqz

New Member
Ok This is the script revised. I still need to figure out how to:

1) Keep special characters (!@#$%^) Out of the first and last name text boxes

2) How can I make it so that no numbers whatsoever can be in the first or last names?

3) How to just clear the text boxes when clear is clicked and leave the info int he textarea alone

4) Also if possible how to sort the info in the textarea

<script language="JavaScript">
<!--
var LastName=new Array();
var FirstName=new Array();
var PhNumber=new Array();
var PhNumber1=new Array();
var PhNumber2=new Array();

function postPhoneList()
// this will be called by FormCheck to enter info into the Textarea

{
document.myPhoneBook.myList.value = "";
for(loopCounter=0;loopCounter<LastName.length; loopCounter=loopCounter+1)
{
document.myPhoneBook.myList.value=
document.myPhoneBook.myList.value +
FirstName[loopCounter] + " " +
LastName[loopCounter] + " : " + "(" +
PhNumber[loopCounter]+ ")" +
PhNumber1[loopCounter]+ "-" +
PhNumber2[loopCounter]+ "\n";
}
}

function FormCheck()
// this will check all values entered into the text boxes

{
var telephone=document.myPhoneBook.phone1.value
var telephone1=document.myPhoneBook.phone2.value;
var telephone2=document.myPhoneBook.phone3.value;
var last=document.myPhoneBook.lastName.value;
var first=document.myPhoneBook.firstName.value;
var validity="true";
var temp= LastName.length;
var size1=telephone.length
var size2=telephone1.length
var size3=telephone2.length
if (first == "")
{
alert("You have left the first name blank. Please enter your first name!");
document.myPhoneBook.firstName.focus();
validity= "false";
}

else if (!(isNaN(first.charAt())))
{
alert("Your first name must be letters only!");
document.myPhoneBook.firstName.focus();
validity="false"
}

else if (last == "")
{
alert("You have left the last name blank. Please enter your last name!");
document.myPhoneBook.lastName.focus();
validity= "false";
}

else if (!(isNaN(last.charAt())))
{
alert("Your last name must be letters only!");
document.myPhoneBook.lastName.focus();
validity="false"
}

else if (telephone== "")
{
alert("Please complete the area code field with 3 numbers. Try again!");
document.myPhoneBook.phone1.focus();
validity= "false";
}

else if (size1 < 3)
{
alert("Please enter 3 numbers for the postal code. Try again!");
document.myPhoneBook.phone1.focus();
validity="false"
}

else if (isNaN(telephone.charAt()))
{
alert("Please enter numbers only in the telephone fields. Try again!");
document.myPhoneBook.phone1.focus();
validity="false";
}


else if (telephone1== "")
{
alert("Please complete the second phone number field with 3 numbers. Try again!");
document.myPhoneBook.phone2.focus();
validity= "false";
}

else if (size2 < 3)
{
alert("Please enter 3 numbers for the second part of the phone number. Try again!");
document.myPhoneBook.phone2.focus();
validity="false"
}

else if (isNaN(telephone1.charAt()))
{
alert("Please enter numbers only in the telephone fields. Try again!");
document.myPhoneBook.phone2.focus();
validity="false";
}


else if (telephone2== "")
{
alert("Please complete the third phone number field with 4 numbers. Try again!");
document.myPhoneBook.phone3.focus();
validity= "false";
}


else if (size3 < 4)
{
alert("Please enter 4 numbers for the last part of the phone number. Try again!");
document.myPhoneBook.phone3.focus();
validity="false";
}

else if (isNaN(telephone2.charAt()))
{
alert("Please enter numbers only in the telephone fields. Try again!");
document.myPhoneBook.phone3.focus();
validity="false";
}


else if (validity=="true")
{
LastName[temp]=last ;
FirstName[temp]=first;
PhNumber[temp]=telephone;
PhNumber1[temp]=telephone1;
PhNumber2[temp]=telephone2;
document.myPhoneBook.firstName.focus();

postPhoneList();

}

}

function tab(obj,OBJ,n)
// this will cause the curser to tab automatically while entering the phone #'s

{
if (obj.value.length >= n)
{
OBJ.focus();
}
}

//-->
</SCRIPT>

</head>

<body background="C:\WINDOWS\Profiles\Ryan\My Documents\Images\Metal1.bmp" script language="javascript">

<h1><u><font color="white" face="arial">My Telephone Book</font></u></h1>

<img src=http://www.webdeveloper.com/forum/archive/index.php/"movingrule.gif">
<form name=myPhoneBook method="get">
<br><br>
<table>

<tr>
<td><h3><font color="white" face="arial">First name:</font>&nbsp;&nbsp;&nbsp;
<input type="text" maxLength="25" name="firstName"></h3></td>
</tr>
<tr>
<td><h3><font color="white" face="arial">Last name:</font>&nbsp;&nbsp;&nbsp;
<input type="text" maxLength="30" name="lastName"></h3></td>
</tr>
<tr>
<td><h3><font color="white" face="arial">Telephone #:</font>
<input type="text" name="phone1" size="3" onKeyup="tab(phone1,phone2,'3')" maxlength="3">
<input type="text" name="phone2" size="3" onKeyup="tab(phone2,phone3,'3')" maxlength="3">
<input type="text" name="phone3" size="4" maxlength="4"></h3></td>
</tr>

<tr>
<td>&nbsp;</td>
</tr>

<tr align="center">

<td><input onclick="FormCheck()"; type="button" name="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Add">&nbsp;
<input type="reset" value="Clear">
</td>
</tr>

<tr>
<td colspan="4"><textarea cols="70" name="myList" rows="15"></textarea>
</td>
</tr>

</table>
</form>
</script>
 
Top