Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在表单中有一个按钮和一个文本字段,当它单击表单时,它会发布到另一个页面。是否有可能有一些 JavaScript 函数在单击按钮时检查文本字段是否包含值?如果单击按钮但该字段为空,我想要的是显示一条消息(警报框)。仅当该字段已填写时,该按钮才应提交。可能的?
谢谢!
当然这是可能的。它甚至是 Web 开发的基础知识。查看此链接以了解如何在提交前验证数据:http: //www.w3schools.com/js/js_form_validation.asp