这是structs吧,判断可以和form一样
<script>if (document.form1.customerTypeCode.value =="" || document.form1.customerTypeName.value=="") {
alert("不能为空");
}
</script>
<script>if (document.form1.customerTypeCode.value =="" || document.form1.customerTypeName.value=="") {
alert("不能为空");
}
</script>
解决方案 »
- 如何在eclipse里面将数据库表映射成为实体类啊?
- 关于创建服务器对象的问题
- JAVA ResultSet 遍历存了map,无法获取最后一行
- java取服务器时间
- 关于java.lang.NumberFormatException: null
- 请问如果要用java代码实现连接池的连接应该怎么写?
- 想问问有没有jsp的在线编辑器!
- 我一个页面,从别的页面接收了参数,当前页没有提交功能,在当前页刷新后,怎样保留从别的页面传过来的参数?不用session
- 用jsp打开word文档!急!!!
- 关于JAVA类设计的请教
- 有用过enterprisedt组件连接ftp的兄弟没有,问个问题
- session禁用的问题!
check() {
if (document.form1.customerTypeCode.value =="" || document.form1.customerTypeName.value=="") {
alert("不能为空");
}
}
</script>
这是Struts的标签,上面的方法行不通!必须在Action或Form中进行判断!我就是不会才问的!哪为大哥帮忙呀?
这样呢?
<html:text property="customerTypeCode"/> 代码
<html:text property="customerTypeName"/> 名字 <script language="javascript">
function checkform(){
if (document.form1.customerTypeCode.value =="") {
alert("不能为空");
document.form1.customerTypeCode.focus();
return false;
}
if (document.form1.customerTypeName.value =="") {
alert("不能为空");
document.form1.customerTypeName.focus();
return false;
}
return true; }
</script>
楼主别忘记给我50分吧,多谢了
HttpServletRequest httpServletRequest) {
ActionErrors errors = new ActionErrors();
这里首先设置错误,然后在跳到一个文件中处理错误,根据错误类型自动转向到刚才的页面并在文本框上面显示:输入不能为空! 上面的方法都不行!!
抱歉,这块我也不太熟悉,提供一个思路可以参考.多多指正.
可以在validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest)方法里面做合法性检查,检查完了,错误信息就放到request里面.
比如request.setAttribute("errormsg", msg);页面上就提供一个javascript方法,在onload时间里面调用,判断"errormsg"里面是否有信息,有的话就alert出来了.思路是这样,既然你用到了struts还有validate的插件,根据你的架构修改了.