www.webdeveloper.com
Results 1 to 2 of 2

Thread: Data Valadation

  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Data Valadation

    Hi there,

    Iv recently started a new job & have been asked to ammened a website the person who used to work here had made. It's a small company site with a shopping cart system. There are a few problems that I need to address but ive know idea how as I only have a basic understanding of HTML & java is new to me.

    I'll list each problem I have after each one has been sorted to save pasting reams of code.

    The first problem I have is the data valadation on the shopping cart page. If a user puts any number of the same item in there shopping cart & then views the shopping cart they are able to ammend the quantities. (Only with a positive number) But if a user has more than one type of item in the shopping cart and tries to update either of the items it throws up the error "invalid quantity" which it shouldnt do. It should update the quantity in the item that it is told to. Now like I said ive got no idea about java script & only a very basic knowledge of html. Could someone please help me with this. Ive pasted the code below.

    Kind Regards

    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- hide JS code
    var justValidating = true
    function validateForm(f){
    var val = f.item.value;
    if(/^\d{1,}$/.test(val)){
    return true;
    }else{
    f.item.focus;
    alert('Invalid Input for quantity');
    return false;
    }

    }


    // end JS hide -->
    </SCRIPT>
    </head>
    <body bgcolor="#FFFFFF" vlink="blue"><form METHOD="get" ACTION="qtyupd.asp" target="_parent" onsubmit="return validateForm(this)">
    <div align="center">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
    <tr valign="top">
    <td height="95%">
    <div align="center">
    <p><font size="5"><b><font face="Arial, Helvetica, sans-serif">Your
    Shopping Cart</font></b></font></p>
    <p>&nbsp;</p>
    </div>
    <table width="550" border="1" align="center" bordercolor="#000000" cellspacing="0" height="55">
    <tr bgcolor="#333366">
    <td height="25">
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="310"><font size="2"><b><font face=Arial color=#FFFFFF>&nbsp;Item
    Name</font></b></font></td>
    <td width="90">
    <div align="center"><font size="2"><b><font face=Arial color=#FFFFFF>Unit
    Price</font></b></font></div>
    </td>
    <td width="32">
    <div align="center"><font size="2"><b><font face=Arial color=#FFFFFF>Qty.</font></b></font></div>
    </td>
    <td width="110">
    <div align="center"><font size="2"><b><font face=Arial color=#FFFFFF>Extended
    Price</font></b></font></div>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td height="25">
    <table cellpadding=4 border=0 cellspacing=0 width='550' align="center">

    <tr>
    <td bgcolor=#FFFFFF width="46%"><font face="Arial, Helvetica, sans-serif" size="2"><a href="reverseget.asp?reverseget=Excelstor ESJ340 40gb 7200rpm ATA100 OEM IDE&start=1">Excelstor ESJ340 40gb 7200rpm ATA100 OEM IDE</a></font></td>
    <td bgcolor=#FFFFFF width="11%"> <font face="Arial, Helvetica, sans-serif" size="2"><a href="delitem.asp?item=Excelstor ESJ340 40gb 7200rpm ATA100 OEM IDE" target="_parent"><img src="delete.jpg" height="15" vspace="0" hspace="0" border="0"></a>
    </font></td>
    <td align=RIGHT bgcolor=#FFFFFF width="17%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">30.00</font></div>
    </td>
    <td align=RIGHT bgcolor=#FFFFFF width="6%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">
    <input size=2 maxlength=5 name="item" value="1">
    </font></div>
    </td>
    <td align=RIGHT bgcolor=#FFFFFF width="20%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">30.00</font></div>
    </td>
    </tr>

    <tr>
    <td bgcolor=#FFFFFF width="46%"><font face="Arial, Helvetica, sans-serif" size="2"><a href="reverseget.asp?reverseget=Gainward Fx5500 256MB DVI TV-Out &start=1">Gainward Fx5500 256MB DVI TV-Out </a></font></td>
    <td bgcolor=#FFFFFF width="11%"> <font face="Arial, Helvetica, sans-serif" size="2"><a href="delitem.asp?item=Gainward Fx5500 256MB DVI TV-Out " target="_parent"><img src="delete.jpg" height="15" vspace="0" hspace="0" border="0"></a>
    </font></td>
    <td align=RIGHT bgcolor=#FFFFFF width="17%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">74.79</font></div>
    </td>
    <td align=RIGHT bgcolor=#FFFFFF width="6%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">
    <input size=2 maxlength=5 name="item" value="1">
    </font></div>
    </td>
    <td align=RIGHT bgcolor=#FFFFFF width="20%">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">74.79</font></div>
    </td>
    </tr>

    <!-- html codes and asp codes here to generate the form-->
    <tr bgcolor="#CCCCCC">
    <td align='LEFT' colspan='3' gcolor='#EEEEEE' height="33" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2"><b>Total,
    Less Tax and Shipping & Handling:</b></font></td>
    <td align='RIGHT' width="6%" height="33">
    <div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">2</font></b></div>
    </td>
    <td align='RIGHT' width="20%" height="33">
    <div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">104.79 </font></b></div>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <div align="center">
    <p> </p>
    <table width="400" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <div align="center"><a href="continue.asp?prodid=311" target="_parent"><img src="return.gif" alt="CONTINUE SHOPPING" border="0" width="93" height="35"></a></div>
    </td>
    <td>
    <div align="center">
    <input type="IMAGE" src="update.gif" border="0" name="UPDATE QUANTITIES" width="93" height="35">
    </div>
    </td>
    <td>
    <div align="center"><a href="emptycart.asp" target="_parent"><img src="clear.gif" alt="EMPTY CART" border="0" width="93" height="35"></a></div>
    </td>
    <td>
    <div align="center"><a href="checkout.asp"><img src="checkout.gif" alt="CHECKOUT" border="0" width="93" height="35"></a></div>
    </td>
    </tr>
    </table>
    </div>

    </form>





    </body></html>

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    That's Javascript, not Java.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles