
07-20-2007
|
| Senior Member
Join Date: Jun 2007
Posts: 1,399
BRL$: 4,187.66 Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 175 | | why doesnt this alert() show? Hey guys,In the middle of writing a form validation script but the final alert message i want to use isnt showing. if you lok at the code you will see the one i mean. What have i done wrong?Code:---------Untitled Documentfunction validateThis(obj){ // form fields to check var fieldRequired = Array("name", "email", "phone"); // text for alert box if field is empty var fieldDescription = Array("Your Name", "Your Email", "Your Phone Number"); // add the default text of your form var defaultText = "empty"; // The beginning of the alert dialogue if fields are empty, keep \n at the end to preserve formatting var alertMsg = "Please complete the following fields\n"; // loop through each field in fieldRequired and make an alert box to show the information for (var i = 0; i < obj.length; i++){ // alert("The " + fieldRequired[i] + "is " + obj.elements[fieldRequired[i]].value); // debugging to run through each required value if (obj.elements[fieldRequired[i]].value == "" || obj.elements[fieldRequired[i]].value == defaultText){ alert(fieldRequired[i] + " isn't set"); //debugging to check fields not set //alertMsg += "test"; } else { alert(fieldRequired[i] + " has been set"); } } alert("this alert doesnt get displayed");} Name:
Phone:
Email:
_uacct = "UA-139461-1";urchinTracker();--------- To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts. | |
__________________ To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
BRL AnswerZ !!! - Share Knowledge, Help Others,
Earn Points. | | | |