<script language="javascript">
function showship(show){
if(show.checked){
document.getElementById("test").style.display = 'none';
}
else
{
document.getElementById("test").style.display = 'block';
}
}
function handler(where){ //check for unusual characters
var iChars="!@#$%^&*()+=-[]\\\';,./{}|\":<>?",wspace = " ";
for(var i=0;i<where.value.length;i++){
if(iChars.indexOf(where.value.charAt(i))!=-1){return false}
if(wspace.indexOf(where.value.charAt(i))!=-1){return "nope"}
}
}
function emailhandler(where){ //check for unusual characters
var iChars = "!#$%^&*()+=-[]\\\';,/{}|\":<>?",wspace = " ";
for(var i = 0; i < where.value.length; i++){
if(iChars.indexOf(where.value.charAt(i)) != -1){return false}
if(wspace.indexOf(where.value.charAt(i)) != -1){return "nope"}
}
}
function isNumberKey(evt,where){
var charCode=(evt.which)?evt.which:event.keyCode;
if(charCode!=8){
var count=where.value.length;
if(count===0){where.value="("}
if(count==4){where.value+=")"}
if(count==8){where.value+="-"}
if(charCode>31&&(charCode<48||charCode>57)){return false}
else{return true}
}
else{return true}
}
function checkform(){
var mycount=document.getElementsByTagName("input").length;
var good=true;
for(i=0;i<=mycount;i++){
//alert(document.getElementsByTagName("input")[i].id);
var current=document.getElementsByTagName('input')[i];
current.style.border="1px solid";
//check email
if(current.id=="email"){
if(current.value!==""){
var test=emailhandler(current);
if(test=="nope"){
alert("Your Email Address can not contain spaces!");
//good=false;
}
if(test===false){
alert("Your Email Address can not contain special characters!");
//good=false;
}
}
}
else{
if(current.id!=="click"){
if(current.value!==""){
var newtest=handler(current);
if(newtest===false){
current.style.border="3px solid red";
alert("You have special characters in the field highlighted \r\n" + current.id);
good=false;
}
}
}
}
}
alert("should Return");
return good;
}
function submitform(){
var check=checkform();
alert(check);
}
</script>
<style type="text/css">
body {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
}
#ship {
visibility: hidden;
}
#test {
display: none;
}
</style>
</head>
<body>
<div id="background">
<div align="center">
<div align="left" style="width:40%">
<div id="uinfo" >
<form name="uform" method="post" action="cust_info_handler.php">
<table>
<tr><td colspan="2">
<div id="top">
User Information
</div>
</td></tr>
<tr><td>
User Name :
</td>
<td>
<?php echo $row['LoginName'];?>
</td>
</tr>
<tr><td>
Password :
</td>
<td>
<input name="password" type="password" id="password" maxlength="15" value="<?php echo $row['Password'];?>" />
</td>
</tr>
<tr><td>
Email :
</td>
<td>
<input name="email" type="text" id="email" value="<?php echo $row['Email'];?>">
</td>
</tr>
</table>
<div id="cinfo" style="width:40%">
<table><tr><td colspan="2"><div id="top">
Contact Information
</div></td></tr>
<tr><td>First Name:</td><td><input name="fname" type="text" id="fname" value="<?php echo $row['Name_First'];?>" size="30"/></td></tr>
<tr><td>Last Name:</td><td><input name="lname" type="text" id="lname" value="<?php echo $row['Name_Last'];?>" size="50" /></td></tr>
<tr><td>Day Phone:</td><td><input name="dphone" maxlength="13" onkeypress="return isNumberKey(event, this)" type="text" id="dphone" value="<?php echo $row['Phone_Day'];?>" /></td></tr>
<tr><td>Message Phone:</td><td><input name="mphone" maxlength="13" onkeypress="return isNumberKey(event, this)" type="text" id="mphone" value="<?php echo $row['Phone_Message'];?>" /></td></tr>
<!---//Cell Phone NEEDED\\ --->
<tr><td>Fax Number:</td><td><input name="fax" maxlength="13" onkeypress="return isNumberKey(event, this)" type="text" id="fax" value="<?php echo $row['Fax'];?>" /></td></tr>
<tr><td>Company Name:</td><td><input name="cname" type="text" id="cname" value="<?php echo $row['CompanyName'];?>" size="120"/></td></tr>
<tr><td>Website:</td><td><input name="www" type="text" id="www" value="<?php echo $row['WebAddress'];?>" size="120"/></td></tr>
</table>
</div>
<div id="minfo">
<table>
<tr><td colspan="2"><div id="top">
Mailing Address
</div></td></tr>
<tr><td>Street Address 1:</td><td><input name="maddress" size="45" type="text" id="maddress" value="<?php echo $row['MailAddress1'];?>" /></td></tr>
<tr><td>Street Address 2:</td><td><input name="maddress2" size="45" type="text" id="maddress2" value="<?php echo $row['MailAddress2'];?>" />
<tr><td>City:</td><td><input name="mcity" type="text" id="mcity" value="<?php echo $row['MACity'];?>" /></td></tr>
<tr><td>State:</td><td><input name="mstate" type="text" size="2" maxlength="2" id="mstate" value="<?php echo $row['MAState'];?>" /></td></tr>
<tr><td>Zip: </td><td><input type="text" id="mzip" value="<?php echo $row['MAZip'];?>"/></td></tr>
<tr><td>Country:</td><td><input name="mcountry" type="text" id="mcountry" value="<?php echo $row['MACountry'];?>" /></td></tr>
</table>
</div>
Ship to same address: <input name="vship" type="checkbox" id="vship" checked="checked" onclick="showship(this)" />
<div id="test">
<table>
<tr><td colspan="2"><div id="top">Shipping Address</div></td></tr>
<tr><td>Street Address 1: </td><td><input type="text" id="saddress" value="<?php echo $row['ShippingAddress1'];?>"/></td></tr>
<tr><td>Street Address 2: </td><td><input type="text" id="saddress2" value="<?php echo $row['ShippingAddress2'];?>"/></td></tr>
<tr><td>City: </td><td><input type="text" id="scity" value="<?php echo $row['SACity'];?>"/></td></tr>
<tr><td>State: </td><td><input type="text" id="sstate" value="<?php echo $row['SAState'];?>"/></td></tr>
<tr><td>Zip: </td><td><input type="text" id="szip" value="<?php echo $row['SAZip'];?>"/></td></tr>
<tr><td>Country: </td><td><input type="text" id="scountry" value="<?php echo $row['SACountry'];?>"/></td></tr>
</table>
</div>
<div><br><input type="button" name="click" id="click" value="submit" onclick="submitform()" ></div></div>
</form>
</div>
</div>
</body>
</html>