button里面的onclick事件没有执行

花轮2580 2016-11-15 10:50:54
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>login</title>
</head>

<body>
<div align="center" >
<form action="insert.php" method="post" name="myform">
用户名: <input type="text" name="username" placeholder="请输入用户名"/> <br/>
密码: <input type="password" name="password" placeholder="请输入密码"/><br/>
确认密码<input type="password" name="repassword"placeholder="请再一次输入密码"/><br/>
<button type="button" name="注册" onclick="register()" class="submit_button">注册</button>
<button type="button" class="submit_button" name="重置" onclick="register()">重置</button>
</form>
</div>
<script type="text/javascript">
Function register()
{
alert("js函数运行成功");
}
</script>
</body>
</html>
...全文
638 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
无涯大者 2016-11-17
  • 打赏
  • 举报
回复
首先要夯实基础,其次LZ要学会在浏览器里面调试JS ~
lzh_me 2016-11-16
  • 打赏
  • 举报
回复
引用 5 楼 never_compromise2580 的回复:
还有个点就是在button里面去掉type="button"后,点注册会直接把表单提交。而不会执行js代码 本人菜鸟,希望大牛指点。
<input> type 分button 和submit,type不一样,效果也是不一样的。建议你先了解一下基础的知识。
花轮2580 2016-11-15
  • 打赏
  • 举报
回复
还有个点就是在button里面去掉type="button"后,点注册会直接把表单提交。而不会执行js代码
本人菜鸟,希望大牛指点。
花轮2580 2016-11-15
  • 打赏
  • 举报
回复
<body>
<div align="center" >
<form action="insert.php" method="post" name="myform">
用户名: <input type="text" name="username" placeholder="请输入用户名"/> <br/>
密码: <input type="password" name="password" placeholder="请输入密码"/><br/>
确认密码<input type="password" name="repassword"placeholder="请再一次输入密码"/><br/>
<button type="button" name="注册" onclick="register()" class="submit_button">注册</button>
</form>
</div>
</body>
<script type="text/javascript">
Function register()
{
alert("js函数运行成功");
}
</script>

function改成大写了,还是运行不了。。
花轮2580 2016-11-15
  • 打赏
  • 举报
回复
用的dreamweaver
快跑蜗牛哥 2016-11-15
  • 打赏
  • 举报
回复
LZ 用是啥工具啊? Function 这样写 应该有提示的啊!
lzh_me 2016-11-15
  • 打赏
  • 举报
回复
function 小写,please, 规范很重要,很重要,真的很重要。

87,997

社区成员

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

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