Advertisement

基于原生JS的表单前端验证开发

阅读量:
复制代码
    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title>注册页面</title>
    		<script>
    			function checkForm(){
    				alert("aa");
    				/**校验用户名*/
    				//1.获取用户输入的数据
    				var uValue = document.getElementById("user").value;
    				//alert(uValue);
    				if(uValue==""){
    					//2.给出错误提示信息
    					alert("用户名不能为空!");
    					return false;
    				}
    				
    				/*校验密码*/
    				var pValue = document.getElementById("password").value;
    				if(pValue==""){
    					alert("密码不能为空!");
    					return false;
    				}
    				
    				/**校验确认密码

全部评论 (0)

还没有任何评论哟~