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
[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?
it's giving me that error
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 for a project due tonight'document.assign3.field04.options[...].selected' is null or not an object