为什么这个onchange事件没有触发

zhyuan0713 2009-03-18 04:56:00
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'regist.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<script type="text/javascript">
function checkImage(na){
alert('dfdfd');
var img=$(na).value;
var pos=img.lastIndexOf(".");
var lastname=img.substring(pos,img.length);
alert(img);
if(lastname.toLowerCase()!=".jpg"&&lastname.toLowerCase()!=".gif"){
alert("您上传的文件类型为"+lastname+",图片必须为.jpg,.gif类型");
alert(img+""+$(na).value="");
}
$(na).focus();
}
function checkName(val){
alert('aa');
regist.findByName(val,getdata);
}
function getdata(sig){
alert(sig);
if(sig){
$("reg").innerHTML='<font color='red' size=2>用户名不可用</font>';
$("registname").value='';
}else{
$("reg").innerHTML="<font color='red' size=2>*  可用</font>";
}
}
</script>

</head>

<body>
<html:form action="/regist.do?method=save" method="post">
<center>
<table>
<tr>
<td colspan="2" align="center">
用户注册
</Td>
</tr>
<tr>
<td>
<font color="red">*</font>用户名:
</td>
<td>
<html:text property="registname" onchange="checkName(this.value);"/>
  
<span id="reg">
</span>
</td>
</tr>
<tr>
<td>
  个人照片上传:
</td>
<td>
<html:file property="photo" onchange="javascript:checkImage(this.name);"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<html:submit property="submit" value="提交"
onclick="return checkNull();"></html:submit>
  
<html:cancel property="cancel" value="取消"></html:cancel>
</td>
</tr>
</table>
</center>
</html:form>
</body>
</html:html>
...全文
41 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,111

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧