I usually work with PHP so sadly don't have some basic JS principles down.(我通常使用PHP,所以很遗憾没有一些基本的JS原则。)
This is all I want to accomplish--I've seen many posts on this topic but they are usually beyond what I need.(这就是我想要完成的任务 - 我已经看过很多关于这个主题的帖子,但它们通常超出我的需要。)
Here is my form:(这是我的表格:)
<input type="checkbox" name="checkbox" value="check" />
<input type="submit" name="email_submit" value="submit" onclick="----??----" />
The checkbox is a simple "I agree".(复选框是一个简单的“我同意”。) I want the submit button to be pressed and it will only submit if that check box is selected.(我希望按下提交按钮,只有选中该复选框才会提交。)
Here's the thing: I want the simple, cheating way -- no methods -- just some inline code in that form (assuming its not overly long?).(事情是这样的:我想要简单,欺骗的方式 - 没有方法 - 只是那种形式的内联代码(假设它不会过长?)。) This is not a public page, I just need something quick and simple with that type of validation.(这不是一个公共页面,我只需要使用这种类型的验证快速而简单。) If its unchecked, it will throw an alert();(如果未选中,则会抛出alert();) if its checked it will submit via post through php and go on as normal.(如果它被检查它将通过邮件提交通过PHP并继续正常。)
ask by TheLettuceMaster translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…