B
brian
i broke down where i think the problems areas would be.
any help would be greatly appreciated.
where the file is called
<script type="text/javascript" src="k.js">
</script>
the beginning of my form, test.cgi doesnt exsist but i think it should
run the function before the action. Is this correct???
<form name="courseform" action="test.cgi" method="post"
onsubmit="return checkForm(this);">
then my code in the file
not sure if it would be better to do the getElementById or just
theform.last_name.value
I havent finished the script but i think you get the idea.
i know the long number are a bit off the wall but i have to use them
sadly.
well thank you for looking over my code.
brian
<script>
function checkForm(theForm)
{
alert("yes");
var error = "";
error += checkFname(theForm..getElementById('first_name').value);
error += checkLname(theForm.last_name.value);
error += checkPhone(theForm.phone.value);
error += checkEmail(theForm.email.value);
error += checkCntmethod(theForm.00N40000001U1MW.selectedIndex);
error += checkCnttime(theForm.00N40000001U1Mm.value);
error += checkAgency(theForm.company.value);
error += checkAtype(theForm.00N40000001U1MR.selectedIndex);
error += checkAaddress(theForm.street.value);
error += checkAcity(theForm.city.value);
error += checkAcounty(theForm.00N30000001E9CN.value);
error += checkAzip(theForm.zip.value);
error += checkCrsname(theForm.00N40000001U1MN.selectedIndex);
error += checklanguage(theForm.00N40000001U2Z8.selectedIndex);
error += checkPdate(theForm.00N40000001U1Mx.value);
error += checkPtime(theForm.00N40000001U1NF.selectedIndex);
error += checkAdate(theForm.00N40000001U1Li.value);
error += checkAtime(theForm.00N40000001U1Lo.selectedIndex);
error += isEmpty(theForm.notempty.value);
error += isDifferent(theForm.different.value);
if (error != "") {
alert(error);
return false;
}
return false;
}
//checks the first name for null statement and length
function checkFname(fname){
var errror = "";
if(fname ==""){
error = "You did not enter a first name. /n"
}
else if (fname.length < 2 || fname.length > 15){
error = "The name entered is incorrect. /n"
}
return error;
}
//checks last name for null statement
function checkLname(lname){
var errror = "";
if(lname ==""){
error = "You did not enter a last name. /n"
}
return error;
}
function checkPhone(phone){
var errror = "";
if(phone ==""){
error = "You did not enter a phone number. /n"
}
else if(phone.length == 10){
error = "Your phone number is the incorrect length. /n"
}
return error;
}
function checkEmail(email){
var errror = "";
if(email ==""){
error = "You did not enter an email address. /n"
}
return error;
}
//checks the contact method
function checkCntmethod(choice) {
var error = "";
if (choice == 0) {
error = "You did not choose a Best cotact method.\n";
}
return error;
}
function checkCnttime(conTime){
var errror = "";
if(conTime ==""){
error = "You did not enter a contact time. /n"
}
return error;
}
function checkAgency(agency){
var errror = "";
if(agency ==""){
error = "You did not enter your agency's name. /n"
}
return error;
}
function checkAtype(choice) {
var error = "";
if (choice == 0) {
error = "You did not choose an agency type.\n";
}
return error;
}
function checkAaddress(address){
var errror = "";
if(adress ==""){
error = "You did not enter the agency's address. /n"
}
return error;
}
function checkAcity(city){
var errror = "";
if(city ==""){
error = "You did not enter the agency's city. /n"
}
return error;
}
function checkAcounty(county){
var errror = "";
if(county ==""){
error = "You did not enter the agency's city. /n"
}
return error;
}
</script>
any help would be greatly appreciated.
where the file is called
<script type="text/javascript" src="k.js">
</script>
the beginning of my form, test.cgi doesnt exsist but i think it should
run the function before the action. Is this correct???
<form name="courseform" action="test.cgi" method="post"
onsubmit="return checkForm(this);">
then my code in the file
not sure if it would be better to do the getElementById or just
theform.last_name.value
I havent finished the script but i think you get the idea.
i know the long number are a bit off the wall but i have to use them
sadly.
well thank you for looking over my code.
brian
<script>
function checkForm(theForm)
{
alert("yes");
var error = "";
error += checkFname(theForm..getElementById('first_name').value);
error += checkLname(theForm.last_name.value);
error += checkPhone(theForm.phone.value);
error += checkEmail(theForm.email.value);
error += checkCntmethod(theForm.00N40000001U1MW.selectedIndex);
error += checkCnttime(theForm.00N40000001U1Mm.value);
error += checkAgency(theForm.company.value);
error += checkAtype(theForm.00N40000001U1MR.selectedIndex);
error += checkAaddress(theForm.street.value);
error += checkAcity(theForm.city.value);
error += checkAcounty(theForm.00N30000001E9CN.value);
error += checkAzip(theForm.zip.value);
error += checkCrsname(theForm.00N40000001U1MN.selectedIndex);
error += checklanguage(theForm.00N40000001U2Z8.selectedIndex);
error += checkPdate(theForm.00N40000001U1Mx.value);
error += checkPtime(theForm.00N40000001U1NF.selectedIndex);
error += checkAdate(theForm.00N40000001U1Li.value);
error += checkAtime(theForm.00N40000001U1Lo.selectedIndex);
error += isEmpty(theForm.notempty.value);
error += isDifferent(theForm.different.value);
if (error != "") {
alert(error);
return false;
}
return false;
}
//checks the first name for null statement and length
function checkFname(fname){
var errror = "";
if(fname ==""){
error = "You did not enter a first name. /n"
}
else if (fname.length < 2 || fname.length > 15){
error = "The name entered is incorrect. /n"
}
return error;
}
//checks last name for null statement
function checkLname(lname){
var errror = "";
if(lname ==""){
error = "You did not enter a last name. /n"
}
return error;
}
function checkPhone(phone){
var errror = "";
if(phone ==""){
error = "You did not enter a phone number. /n"
}
else if(phone.length == 10){
error = "Your phone number is the incorrect length. /n"
}
return error;
}
function checkEmail(email){
var errror = "";
if(email ==""){
error = "You did not enter an email address. /n"
}
return error;
}
//checks the contact method
function checkCntmethod(choice) {
var error = "";
if (choice == 0) {
error = "You did not choose a Best cotact method.\n";
}
return error;
}
function checkCnttime(conTime){
var errror = "";
if(conTime ==""){
error = "You did not enter a contact time. /n"
}
return error;
}
function checkAgency(agency){
var errror = "";
if(agency ==""){
error = "You did not enter your agency's name. /n"
}
return error;
}
function checkAtype(choice) {
var error = "";
if (choice == 0) {
error = "You did not choose an agency type.\n";
}
return error;
}
function checkAaddress(address){
var errror = "";
if(adress ==""){
error = "You did not enter the agency's address. /n"
}
return error;
}
function checkAcity(city){
var errror = "";
if(city ==""){
error = "You did not enter the agency's city. /n"
}
return error;
}
function checkAcounty(county){
var errror = "";
if(county ==""){
error = "You did not enter the agency's city. /n"
}
return error;
}
</script>