I have a form where I need to do three things.
1. Check for blank fields
2. Upload an image (I can deal with this one)
3. Check to see if a field contains specific information (IE a password)
There is the existing code and I have a small function that is checking for the blank fields and that I would like to change to check for the correct password....
Code:
//function to check empty fields
function isEmpty(strfield1, strfield2, strfield3) {
//change "field1, field2 and field3" to your field names
strfield1 = document.forms[0].fname.value
strfield2 = document.forms[0].lname.value
strfield3 = document.forms[0].password.value
//first name field
if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
{
alert("Your full name is required please enter and try again")
return false;
}
//last name field
if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
{
alert("Your full name is required please enter and try again")
return false;
}
//password field
if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
{
alert("A password is required to upload your photos please try again or contact us to obtain a password")
return false;
}
return true;
}
//function that performs all functions, defined in the onsubmit event handler
function check(photoUpload)){
if (isEmpty(form.fname)){
if (isEmpty(form.lname)){
if (isEmpty(form.password)){
}
}
}
return false;
}
But.... it doesn't work. And I don't know what I did wrong. Well I am sure numerous things but specifically, no idea. Thanks in advance.