form表单校验后,在执行提交动作:
<form method="post" action="{:U(‘Custom/addmsg‘)}" id="massage"> <ul> <li><input name="name" maxlength="18" type="text" placeholder="您的姓名" class="text1" /></li> <li><input name="mobile" maxlength="11" type="text" placeholder="您的手机" class="text1" /></li> <li><textarea name="message" maxlength="300" class="text2" placeholder="您的留言"></textarea></li> </ul> <input type="text" readonly value="提交" class="sub-btn message" /> </form>
js:
//message表单非ajax提交 $(".message").click(function(){ var name = $.trim($("input[name=‘name‘]").val()); var mobile = $.trim($("input[name=‘mobile‘]").val()); var message = $.trim($("textarea[name=‘message‘]").val()); if(name && mobile && message){ $("#message").submit(); })
原文地址:https://www.cnblogs.com/xuzhengzong/p/9128669.html
时间: 2024-11-17 10:28:11