javascript help

FishBoy

Feeeesh
Joined
1 Aug 2004
Messages
1,685
hey it's me again with another programming question,
i have a problem with 2 of my functions:

this function isn't working as it should, it's supposed to fail if the user enters anything other than letters in the name field
i tried the 'isNaN()' function but that did'nt work so i tried doing it manually that didn't work either
Code:
function Field01(){
	if(document.assign3.field01.value==""){
		sErrMsg+="<li> Name field cannot be empty </li>";
		bErrors=true;
	}else if(document.assign3.field01.value.length<2){
		sErrMsg+="<li> Name must contain at least two characters </li>";
		bErrors=true;
	}

	var num=false;
	var pos=document.assign3.field01.value;

	for(i=0;i<=document.assign3.field01.value.length;i++){
		if(pos.charAt(i)>'a') num=true;
		else if(pos.charAt(i)<'z') num=true;
		else if(pos.charAt(i)>'A') num=true;
		else if(pos.charAt(i)<'Z') num=true;
	}
	
	if(num){
		sErrMsg+="<li> Name field must contain letters only </li>";
		bErrors=true;
	}
}

[edit]
ok i got the code below to work it turns out i was supposed to loop i<=5 times only coz i had 5 items only i thought it would work as in C++ and C

but i dont know what's wrong with the code above
[/edit]

this code isn't working, i dont know what's wrong with it?
Code:
function Field04(){
	var check=true;

	for(var i=0;i<6;i++){
		if(document.assign3.field04.options[i].selected){
			check=false;
			break;
		}
	}

	if(check){
		sErrMsg+="<li> Please select an option from the menu list </li>";
		bErrors=true;
	}
}
it's giving me that error
'document.assign3.field04.options[...].selected' is null or not an object
it's for a project due tonight
 
and this function is working backwards, if 1 checkbox is left unchecked it works instead of if 1 checkbox is checked it works
man something must be wrong with all my codes
Code:
function Field05(){
	var check=true;

	for(var i=0;i<6;i++)
		if(document.assign3.element[i].checked==true)
			check=false;

	if(check==true){
		sErrMsg+="<li> Please select one of the check boxes </li>";
		bErrors=true;
	}
}
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back