我正在研究这个样本请求论坛,它与一个篮子一起工作,我通过调整表单来验证它,以便它使用HTML5验证,这是有用的。但在将“提交”按钮更改为“输入按钮”之前,如果购物篮中有超过5个项目,则用它停止表单提交:
<a href="javascript:closeFiveCheck();"> BUTTON </a>
所以现在它验证了表单,但是会让你提交超过5个项目的请求,这是我们不想要的,如果我把它改回锚链接,html5 fourm将不起作用,所以我需要一种方法将两者结合起来。
这是整个论坛:
echo '<form name="SEARCH" id="SEARCH" method="POST" action="orderSamples.php" enctype="multipart/form-data">';
echo '<div class="mainBasketContact">';
echo '<a href="design-search.php"><img src="images/basketLong.png" /></a>';
echo '<p>Enter your details to receive your free samples. Please allow 7 working days for delivery.</p>';
echo '<div class="contactLabel">NAME</div><div class="contactLabel2"><input required="required" style="background:#'.$basketColour.';" type="text" name="NAME" id="NAME" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">COMPANY</div><div class="contactLabel2"><input style="background:#'.$basketColour.';" type="text" name="COMPANY" id="COMPANY" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">EMAIL</div><div class="contactLabel2"><input required="required" type="email" style="background:#'.$basketColour.';" name="EMAIL" id="EMAIL" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">TEL</div><div class="contactLabel2"><input type="number" required style="background:#'.$basketColour.';" name="TEL" id="TEL" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">PROJECT TITLE</div><div class="contactLabel2"><input style="background:#'.$basketColour.';" type="text" name="PROJECT" id="PROJECT" /></div><div style="clear: both;"></div>';
//echo '<div class="contactLabel">ADDRESS</div><div class="contactLabel2"><textarea style="background:#'.$basketColour.';" name="ADDRESS" id="ADDRESS" /></textarea></div><div style="clear: both;"></div>';
echo '<p class="dcHeader1">DELIVERY ADDRESS</p>';
echo '<div class="contactLabel">LINE 1</div><div class="contactLabel2"><input required="required" type="text" style="background:#'.$basketColour.';" name="AD1" id="AD1" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">LINE 2</div><div class="contactLabel2"><input type="text" style="background:#'.$basketColour.';" name="AD2" id="AD2" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">TOWN/CITY</div><div class="contactLabel2"><input required="required" type="text" style="background:#'.$basketColour.';" name="TOWN" id="TOWN" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">POSTCODE</div><div class="contactLabel2"><input required="required" type="text" style="background:#'.$basketColour.';" name="POSTCODE" id="POSTCODE" /></div><div style="clear: both;"></div>';
echo '<div class="contactLabel">FURTHER<br/>NOTES</div><div class="contactLabel2"><textarea name="MESSAGE" id="MESSAGE" style="background:#'.$basketColour.';"></textarea></div><div style="clear: both;"></div>';
echo '<input type="submit" name="Submit" value="SUBMIT" />';
echo '</div>';
echo '<div style="clear: both;"></div>';
echo '</div>';
echo '</form>';
我有一个公平的环顾四周,到目前为止没有运气,如果有人有任何建议请按我的方式扔他们!谢谢! :)
答案 0 :(得分:1)
只需使用表单按钮上的onclick属性,它应该使其行为与之前的链接相同:
<input type="submit" name="Submit" value="SUBMIT" onclick="return closeFiveCheck();" />