Jump to content
Sign in to follow this  
mboehler3

2 Error Messages Given For Same Error

Recommended Posts

Hi I am trying to get my form to recognize when no input has been entered. Currently on the form, I have an autoclear function, which gives each input a value. On two of the inputs, the Phone and Email, I am receiving an error message for an incorrect value and for nothing being entered. Here's a screenshot of the error:error-msg.jpgHere is the HTML for the form:

<table cellpadding="0" cellspacing="0" border="0">	<tr>	<td colspan="2">	<div id="inputWrap"><input class="tb-condensed bold color727272 fontsize10" type="text" size="30" maxlength="50" id="employees" name="employees" value="# of Employees" tabindex="2" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'# of Employees':this.value;" /></div>	</td>	</tr>	<tr>	<td>	<div id="inputWrap"><input class="tb-condensed bold color727272 fontsize10" type="text" size="30" maxlength="50" id="firstname" name="firstname" value="First Name" tabindex="2" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'First Name':this.value;" /></div>	</td>	<td>	<div id="inputWrap"><input class="tb-condensed bold color727272 fontsize10" type="text" size="30" maxlength="50" id="lastname" name="lastname" value="Last Name" tabindex="2" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Last Name':this.value;" /></div>	</td>	</tr>	<tr>	<td>	<div id="inputWrap"><input class="tb-condensed bold color727272 fontsize10" type="text" size="30" maxlength="50" id="email" name="email" value="Email" tabindex="2" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Email':this.value;" /></div>	</td>	<td>	<div id="inputWrap"><input class="tb-condensed bold color727272 fontsize10" type="text" size="30" maxlength="50" id="phone" name="phone" value="Phone Number" tabindex="2" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Phone Number':this.value;" /></div>	</td>	</tr>	<tr>	<td colspan="2">	What's Your Payroll Frequency?	<div id="inputWrap" style="padding-bottom:5px;">	<select name="PayrollFrequency" tabindex="9" />	<option value='0'>Select one</option>	<option value="W">Weekly</option>	<option value="BW">Bi-Weekly</option>	<option value="S">Semi-Monthly</option>	<option value="M">Monthly</option>	</select></div>	</p>	</td>	</tr>	<tr>	<td colspan="2">	What's Your Current Payroll Method?	<div id="inputWrap" style="padding-bottom:10px;">	<select name='PayrollMethod' tabindex="10" />	<option value='0'>Select one</option>	<option value='New Business'>New Business</option>	<option value='In House'>In House</option>	<option value='Not Currently Processing'>Not Currently Processing</option>	<option value='Accountant'>Accountant/Bookkeeper</option>	<option value='Payroll Service'>Payroll Service</option>	<option value='PEO/Leasing Company'>PEO/Leasing Company</option>	<option value='Other'>Other</option>	</select></div>	</p>	</td>	</tr>	<tr>	<td colspan="2">	   <input type="image" src="/images/960/payroll/payroll-submit.gif" tabindex="11" alt="Get Instant Quote" id="submit2" name="submit2" />	</td>	</tr>	</table>

And here's my JS:

							function checkquotevalues(){								message="";																if(document.quotesform1.employees.value =='# of Employees'){												message = message+"Please enter a # of Employees.\n";								}								else								{								if(document.quotesform1.employees.value.length != 4){										if(IsNumeric(document.quotesform1.employees.value) != 1){										message = message+"Please enter a Numeric # of Employees.\n";										}										}										else 										{ message = message+"Please enter a # of Employees.\n";}								}								if(document.quotesform1.firstname.value.length ==0){												message = message+"Please enter a First Name.\n";								}									if(document.quotesform1.firstname.value =='First Name'){												message = message+"Please enter a First Name.\n";								}								if(document.quotesform1.lastname.value.length ==0){												message = message+"Please enter a Last Name.\n";								}								if(document.quotesform1.lastname.value =='Last Name'){												message = message+"Please enter a Last Name.\n";								}								if (document.quotesform1.email.value =='Email'){										message = message+"Please enter your Email Address.\n";									}								if (document.quotesform1.email.value.length ==0){										message = message+"Please enter your Email Address.\n";									}									else {									 	checkemail(document.quotesform1.email.value)									}																if(document.quotesform1.phone.value =='Phone Number'){												message = message+"Please enter a Phone Number.\n";								}								if(document.quotesform1.phone.value.length != 10){										if(IsNumeric(document.quotesform1.phone.value) != 1){										message = message+"Please enter a Numeric Phone Number.\n";										}										else										 { message = message+"Please enter a Phone Number.\n";}								}								else{ 									if(IsNumeric(document.quotesform1.phone.value) != 1){									message = message+"Please enter a Numeric Phone Number.\n";									}								}								if(document.quotesform1.PayrollFrequency.selectedIndex == 0){										message = message+"Please enter a Payroll Frequency.\n";								}								if(document.quotesform1.PayrollMethod.selectedIndex == 0){										message = message+"Please enter a Payroll Method.\n";								}																if (message.length > 0){											alert(message);										return false;									}																					return true;								}															function checkemail(str){								var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i								if (filter.test(str))								testresults=true								else{								message = message + "Email address seems incorrect (check @ and .'s)\n"								return false;								}								}							function IsNumeric(sText)								{								   var ValidChars = "0123456789";								   var IsNumber=true;								   var Char;																 								   for (i = 0; i < sText.length && IsNumber == true; i++) 									  { 									  Char = sText.charAt(i); 									  if (ValidChars.indexOf(Char) == -1) 										 {										 IsNumber = false;										 }									  }									 return IsNumber;	   							}

Share this post


Link to post
Share on other sites

You need another else, e.g.:

								if (document.quotesform1.email.value =='Email'){										message = message+"Please enter your Email Address.\n";									}								else if (document.quotesform1.email.value.length ==0){										message = message+"Please enter your Email Address.\n";									}									else {										 checkemail(document.quotesform1.email.value)									}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...