I am back. And slowly learning... slowly...
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:<form id="photoUpload" enctype="multipart/form-data" onsubmit="return check(this);" runat="server"> <fieldset> <legend>Share your pictures with us</legend> <p align="right"><label for="fname">First Name<em>*</em></label> <input id="fname" /></p> <p align="right"><label for="lname">Last Name<em>*</em></label> <input id="lname" /></p> <p align="right"> <label for="fulPhoto">Upload your image</label> <input id="fulPhoto" type="file" runat="server"/></p> <p align="right"> <label for="thbPhoto">Upload your image</label> <input id="thbPhoto" type="file" runat="server"/></p> <p><label for="password">Password<em>*</em></label> <input id="password" type="password" /></p> <div class="btn" id="thbUpload" style="padding-top:4px"> <input id="btnUpload" type="button" value="Upload Photo" onclick="passwordBox()" /> </div> </fieldset> </form>
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.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; }


Reply With Quote

Bookmarks