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);">
    你可以比现在做得更好
  • 相关阅读:
    JZOJ5809 数羊
    P3313 [SDOI2014]旅行
    2019.10.22 NOIP模拟测试 day2
    P4322 [JSOI2016]最佳团体
    P1850 换教室
    P3225 [HNOI2012]矿场搭建
    P2607 [ZJOI2008]骑士
    2019.10.21 NOIP模拟测试 day1
    AFO
    禁止加载浏览器图片
  • 原文地址:https://www.cnblogs.com/hwm-php/p/3565519.html
Copyright © 2011-2022 走看看