form提交时进行判断

复制代码
.error {border:#ff0000 1px solid;background: rgba(195,5,5,.2);}

<form action="#" method="post" onsubmit="return checkForm(this);"> </form> function checkForm(obj) { if($('#username').val() === ''){ $('#username').addClass('error'); return false; } }

//点击或选择文本框时,让错误提示消失
$(function (){
$('select').click(function (){
$(this).removeClass('error');
})
$('input').click(function (){
$(this).removeClass('error');
})
})
 
复制代码

 

posted @   赵瑛  阅读(112)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战

版权所有 © 2022 沅来是澧

如果有程序开发、网站建设等需求的请联系我,QQ:47419233

点击右上角即可分享
微信分享提示