zoukankan      html  css  js  c++  java
  • js表单验证

    用js验证表单提交时不能为空的代码:

     
    <script type="text/javascript">
     function check(form){
      with(create_apply_form){
       if(profession.value == ""){
        alert("专业名称不能为空");
        return false;
       }
       if(classes.value == ""){
        alert("班级不能为空");
        return false;
       }
       if(name.value == ""){
        alert("姓名不能为空");
        return false;
       }
       if(student_number.value == ""){
        alter("学号不能为空");
        return false;
       }
       if(contact_way.value == ""){
        alter("联系方式不能为空");
        return false;
       }
       if(apply_item_id.value == ""){
        alter("已报名的项目id不能为空");
        return false;
       }
       return true;
      }
     }
    </script>
     
     
    在表单中input框submit中要写多一句:onclick="return check(form);":即
    <input type="submit" value="新增" onclick="return check(form);">
    你可以比现在做得更好
  • 相关阅读:
    负载均衡session会话保持方法
    PHP分布式中Redis实现Session
    Nginx内置变量
    Nginx配置文件解析
    Nginx重写
    Nginx与Apache比较
    CGI概念
    Linux笔记(十四)
    Linux笔记(十三)
    hdu 4039
  • 原文地址:https://www.cnblogs.com/hwm-php/p/3565519.html
Copyright © 2011-2022 走看看