简体   繁体   中英

Number & Decimal Validations using Jquery

I need to implement following validations.Please suggest any jQuery plugin for this.

Case -1

Numeric Number Range : (0-9999) Non Negative Non Decimal

Case -2

Numeric Number Range : (0-99.99) Non Negative Decimal with more than 2 digits after decimal is not allowed

Case -3

Numeric Number Range : (0-99999) Non Negative Decimal @ first position or last position

better use server side validations, javascript validations are client-side and can be hacked easily

Edit: using the jQuery validation plugin

$("#myform").validate({
  rules: {
    field: {
      required: true,
      range: [0,9999]
    }
  }
});

The second case is a bit strange, are you passing strings to the database? try with

number: true
max: 99.99
min: 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM