自定义js文件

 时间:2026-02-13 03:40:32

1、首先创建js文件,然后编写js内容,可以使用原生js,也可以使用jquery的方式写。 var a=document.getElementById(id).value;

var b =$(id).val();

获取节点的值使用这两种方式都是可以的,

自定义js文件

2、如果不是使用的原生js写的,那么必须引入jquery才可以生效,也就是说,第二种方式是依赖jquery的;

自定义js文件

3、function checkName(id){ var a=document.getElementById(id).value; if(a==null||a=="用户名不能为空"||a==""){  $('#ename').val('用户名不能为空');  return false; } return true;}

自定义js文件

4、简单的弹出对话框

function alertHello(id){ alert(id)}

非空验证function checkNull(id){ var a = $(id).val(); if(a==null || a==""){  return false; } return true;}

自定义js文件

1、 jQuery("#theForm").validate({ ignore: "",     rules: {         goods_class_id:{        required:true   },    goods_serial:{        maxlength:20   },   goods_name:{        required:true,     minlength:3,     maxlength:50       },  

自定义js文件

2、  goods_price:{       required:true,    number:true,    range:[0.01,1000000]    },    goods_weight:{    number:true    },   goods_volume:{    number:true    },    store_price:{       required:true,    number:true,    range:[0.01,1000000]    },   

自定义js文件

3、 goods_inventory:{       number:true,    range:[1,1000000000]    },    transport_id:{transportId:true}   },     messages: {         goods_class_id:{required:"商品分类不能为空"},   goods_serial:{maxlength:"输入字符长度不得超过20"},   goods_name:{       required: "商品名不能为空",       minlength:"商品名最少为3个字符",       maxlength:"商品名最多为50个字符"     },   goods_price:{       required:"商品原价不能为空",    number:"商品原价只能是数字格式",    range:"商品价格只能在0.01-1000000之间"    }, 

自定义js文件

  • 如何用PHP往MySQL中插入数据
  • 在VScode中如何设置水平滚动条自动可见
  • myeclipse版本怎么查看
  • js如何改变日期中的月份
  • thinkphp如何在html页面输出数据库数据
  • 热门搜索
    苹果5什么时候上市的 排卵期什么时候 又什么又 什么是logo 给老师送什么花 岁次是什么意思 white是什么意思中文 什么是主语 拜金女是什么意思 叶酸什么时候吃最好