No replies
orit_v2003
Offline
Regular
Last seen: 13 years 16 weeks ago
Joined: 2006-11-12
Posts: 18
Points: 0

Hi,
I have a form.
I want to let the client that fills the form to write his home or mobile phone number. The client can fill both the fields or one of the 2.

I tried to put a flag that cheacks if one of the 2 are filled but i guess i didn't do it right cause it ain't working.

Here is the form:

				<form action="http://cp.responder.co.il/subscribe.php" method="post" onSubmit="return responder_validation()" id="rspform" >				
                <table id="tform" align="right" cellpadding="0" cellspacing="5" border="0">
					<tr>
						<td id="label">first name:</td>
						<td id="control"><input id="inputText" name="fields[subscribers_name]" type="text" maxlength="20"></td>
					</tr>
					<tr>
						<td id="label">family name:</td>
						<td id="control"><input id="inputText" name="fields[family_name]" type="text" maxlength="30" /></td>
					</tr>
					<tr>
						<td id="label">email:</td>
						<td id="control"><input id="inputText" name="fields[subscribers_email]" type="text" maxlength="50" /></td>
					</tr>
 
					<tr>
						<td id="label">phone:</td>
						<td id="control"><input id="inputPhone" name="fields[phone]" type="text" maxlength="20" /> </td>
					</tr>
 
					<tr>
						<td id="label">mobile:</td>
						<td id="control"><input id="inputPhone" name="fields[mobile]" type="text" maxlength="20" /> </td>
					</tr>
 
 
 
					<tr>
						<td id="label">subject:</td>
						<td id="control"><input id="inputText" name="fields[subject]" type="text" maxlength="50" /></td>
					</tr>
 
 
					<tr>
						<td id="label">comments:</td>
						<td id="control"><textarea id="inputTextArea" name="fields[comments]"></textarea></td>
					</tr>
					<tr>
						<td id="label"></td>
						<td id="control"><input type="submit" value="send">  
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="reset" name="clear" value="clear" id="inputButton"></td>
					</tr>
				</table>
 
 
				<!--<input type="hidden" name="form_id" value="">				-->
			</form>

Here is the javascript:

<!-- Generated by responder.co.il -->
<script language="JavaScript" type="text/javascript">
<!--
function responder_validation()
{
    var flag = false
    var rspform = document.getElementById("rspform");
    var listitems= rspform.getElementsByTagName("input");
 
 
 
 
 
 
for (a=0;a<listitems.length;a++)
{ switch (listitems[a].name)
  {
 
	case 'fields[subscribers_email]':	var reEmail = /^[-\w\d\.]+@[-\w\d\.]+\.[-\w\d\.]+$/;
										if(listitems[a].value == "")
											{   alert("please fill in your email");listitems[a].focus();return false;}
										if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(listitems[a].value)))
											{   alert("your email is not correct.");listitems[a].focus();return false;}
										break;
	case "fields[subscribers_name]":			if(listitems[a].value == "")
											{   alert("Please fill in your name");listitems[a].focus();return false;}
										break;
 
 
 
	case "fields[phone]":			if(listitems[a].value != "")
											{   flag=true;}
 
	case "fields[mobile]":			if(listitems[a].value != "")
											{  flag=true;}
 
 
	case "fields[subject]":		
												if(listitems[a].value == "")
										{   alert("Please right the subject");listitems[a].focus();return false;}
								break;
 
 
  }
}
 
 
if (flag==false)
{
	alert("Please fill in your Home phone or mobile number");
	return false;
 
}
 
 
 
 
				}
				//-->
				</script>

Please help...

Tags: