zoukankan      html  css  js  c++  java
  • jquery相关校验以及jquery其他知识总结

    //************jquery校验**********/

    //数字校验(整数)
    function isDigit(str) {
    var patrn=/^[0-9]*$/;
    return patrn.test(str);
    };

    如果是判断数字,包括小数。可以使用其自带的isNaN()方法来实现。如果不是数字,那么就返回true.

    //非中文信息的校验

    /^[^u4e00-u9fa5]*$/

    上面一段表达式是判断非中文的。主要用于校验是不是不包含中文。

     //身份证判断(要么为空,要么为省份证格式)

    re =  /^$|^[1-9]d{5}[1-9]d{3}((0d)|(1[0-2]))(([0|1|2]d)|3[0-1])d{3}([0-9]|X)$/

    //*************jquery对css的超控*******/

    //通过jquery事件添加样式。

    $("#zippost1").css("display","inline");

    //*************jquery对标签的操控*******/

    //通过jquery事件,追加一个提示框(或删除)

    $("#testInput").append("<font id="mes">不能为空</font>");

    $("#mes").remove();

    //js选择radio,并设置选中哪个(有两个一个值为0,一个值为1)

    jQuery(":radio[id=return_no_reason]").eq(0).attr("checked","checked");
    jQuery(":radio[id=return_no_reason]").eq(1).removeAttr("checked");

    //js对select的操作

    <select>
      <option value="1">一号</option>
      <option value="2">二号</option>
        <option value="3">三号</option>
    </select>  

    $("#selectId").val(1); //这里是通过js选择值为1的那个选项

    //js对checkbox的操作

    <input  type="checkbox"  name="testCheck" id="testCheck"/> 

     var isChecked = $("#testCheck").attr('checked')//获取当前checkbox是否被选中,jquery1.6之前返回true||false.但之后返回checked||unchecked.如果一开始没被选中,

                                                                        则返回的是undefined

    var  isChecked = $("#testCheck").is(":checked")  //获取当前checkbox是否被选中   jquery1.6之后返回true  or  false

  • 相关阅读:
    49. 字母异位词分组
    73. 矩阵置零
    Razor语法问题(foreach里面嵌套if)
    多线程问题
    Get json formatted string from web by sending HttpWebRequest and then deserialize it to get needed data
    How to execute tons of tasks parallelly with TPL method?
    How to sort the dictionary by the value field
    How to customize the console applicaton
    What is the difference for delete/truncate/drop
    How to call C/C++ sytle function from C# solution?
  • 原文地址:https://www.cnblogs.com/wangxiangstudy/p/5028977.html
Copyright © 2011-2022 走看看