WebView_html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>myHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<!-- 此处编写JavaScript --js -->
<script language="javascript">
//定义函数,验证表单信息是否合法
function checkAll(ele) {
alert(ele);
//验证用户名不为空
var name = document.getElementById("id1");//得到用户名输入框对象
var nameValue = name.value;//得到具體的值
if (nameValue.length <= 0) {//驗證
// document.getElementById("div1").innerHTML="<font size='4' color='red'>用户名不能为空</font>";
alert("用户名不能为空,请填写");
return;
} else {
document.getElementById("div1").innerHTML = "";
}
//驗證密碼
var pass = document.getElementById("id2");//得到密码输入框对象
var passValue = pass.value;
if (passValue.length < 6) {
// document.getElementById("div2").innerHTML="<font size='4' color='red'>密码长度不能小于6位</font>";
alert("密码长度不能小于6位");
return;
} else {
document.getElementById("div2").innerHTML = "";
}
//验证邮箱
var email = document.getElementById("id3");//得到邮箱输入框对象
var emailValue = email.value;
if (emailValue.indexOf("@") == -1) {
//普通的js代码可以通过设置WebSetting实现有效
// document.getElementById("div3").innerHTML="<font size='4' color='red'>邮箱不包含@!</font>";
alert("邮箱不包含@,请检查!");//通过webchromClient设置有效
return;
} else {
document.getElementById("div3").innerHTML = "";
}
//输入项都符合要求,提交表单,但是做一个确认的提醒
if (confirm("确认提交吗?")) {
//document.getElementById("form1").submit();
window.myclass.senData(nameValue, passValue, emailValue);
}
}
</script>
</head>
<body>
<form id="form1" action="success.html">
<center>
<table>
<tr align="center">
<td colspan="2"><a href="http://www.baidu.com">百度</a></td>
</tr>
<tr>
<td>用户名:</td>
<td width="150"><input type="text" id="id1" name="username" />
<div style="display: inline" id="div1"></div></td>
</tr>
<tr>
<td>密码:</td>
<td width="150"><input type="password" id="id2"
name="userpass" />
<div style="display: inline" id="div2"></div></td>
</tr>
<tr>
<td>邮箱:</td>
<td width="150"><input type="text" id="id3" name="email" />
<div style="display: inline" id="div3"></div></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="button"
onclick="checkAll('开始验证');" value="提交(app)" /></td>
</tr>
</table>
<center>
</form>
</body>
</html>