<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="http://www.baidu.com" onsubmit="return toVaild()">
<input type="text" id="ff"> <input type="submit" id="submit" value="提交" /> </form>
</body>
<script language="javascript">
function toVaild() {
var val = document.getElementById("ff").value;
// alert(val);
if (val == "可以提交") {
alert("校验成功,之后进行提交");
return true;
} else {
alert("校验失败,不进行提交");
return false;
}
}
</script>
</html>