PHP5000 Posted November 24 Share Posted November 24 (edited) Hi I have a simple form which contain a drop down menu for quantity. After quantity is selected a script does a cost calculation and value is shown. However the user should not be able to proceed without selecting quantity. I am getting all sorts of illogical outcomes after each change or correction I make. Initially the validation would just ignore the Quantity and check the second item. Then after some changes to the code, now it keeps asking for Quantity even after the user has selected from the list. Here is the code, do you see any errors? Thanks in advance. print "<script> function validateForm() { let xss = document.forms[\"frmCustomize\"][\"SQty\"].value; if (xss == \"0\") { alert(\"Please select quantity\"); return false; } var fffnnn = document.forms[\"frmCustomize\"][\"CCnumber\"].value; if (fffnnn == null || fffnnn == \"\") { alert(\"Please enter your card number.\"); return false; } </script>"; the form : print "<form action=M1.php method=POST id=C4 onsubmit=\"return validateForm()\" name=frmCustomize>"; // **************** QUANTITY ******************* print "<tr><td valign=top><b>Quantity:</td> <td valign=top> <select name=SQty id=SQty onchange=\"CalculateTotal()\"> <option value=0>Please select quantity</option> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> <option value=5>5</option></select></td></tr>"; Edited November 24 by PHP5000 Quote Link to comment https://forums.phpfreaks.com/topic/325634-solved-form-validation-works-funny/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.