hi all,
in my below code there is an alert message for only the name i.e..
customer after shopping he is supposed to enter his details so in my below code only name
is mandatory but i want both the email and phone number alo should be mandatory
i.e.,email should be of valid type and phone number should be of 10 digits only.
kindly tell me how to do the two using alert box only.....
PHP Code:
<?php
include("db.php");
include(
"functions.php");
if(
$_REQUEST['command']=='update')
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$phone=$_REQUEST['phone'];
$result=mysql_query("insert into customers values('','$name','$email','$phone')");
$customerid=mysql_insert_id();
$date=date('Y-m-d');
$result=mysql_query("insert into orders values('','$date','$customerid')");
$orderid=mysql_insert_id();
    
$max=count($_SESSION['cart']);
for(
$i=0;$i<$max;$i++)
{
  
$pid=$_SESSION['cart'][$i]['productid'];
  
$q=$_SESSION['cart'][$i]['qty'];
  
$price=get_price($pid);
  
mysql_query("insert into order_detail values($orderid,$pid,$q,$price)");
}
 die(
'Thank You! Your Order Has Been Placed!');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Billing Information</title>
<script type="text/javascript">
function validate()
 {
  var f=document.form3;
  if(f.name.value=='')
   {
    alert('Your name is required');
    f.name.focus();
    return false;
   }
    f.command.value='update';
    f.submit(); 
 }
</script>
</head>
<body>
<form name="form3" onsubmit="return validate()">
 <input type="hidden" name="command" />
  <div align="left">
     <h1 align="left">Billing Information</h1>
       <table border="0" cellpadding="2px">
        <tr><td>Order Total:</td><td><b><?php echo "$" get_order_total() ?></b></td></tr>
        <tr><td>Cust Name:</td><td><input type="text" name="name" /></td></tr>
        <tr><td>Email:</td><td><input type="text" name="email" /></td></tr>
        <tr><td>Phone:</td><td><input type="text" name="phone" /></td></tr>
        <tr><td></td><td><input type="submit" value="Place Order" /></td></tr>
       </table>
  </div>
</form>
</body>
</html>