Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

step automatic rule gets broken for very small steps #2469

Open
@bderleta

Description

@bderleta

Your environment

  • Version ofjquery-validate: 1.19.5
  • Browser name and version: Firefox 116.0.2

Current behavior

Wheninput[type="number"] has an attributestep with value of magnitude smaller than approx. 1e-7, thestep rule has its value assigned in an exponential form, causing regular expression not to being matched.

Expected behavior

Proper input validation, taking actual number of decimal places into account.

Live demo

https://jsfiddle.net/ydj8o4nu/

Hotfix proposal

After reconsideration, I see it might not cover all possible cases, but alternate solutions liketoLocaleString are even more dodgy.

decimalPlaces = function( num ) {  var exponentialMatch = ( "" + num ).match( /(?:e\-(\d+))?$/ );  if ( exponentialMatch && exponentialMatch[1] ) {    return parseInt(exponentialMatch[1]);  }                  var match = ( "" + num ).match( /(?:\.(\d+))?$/ );  if ( !match ) {    return 0;  }    // Number of digits right of decimal point.  return match[ 1 ] ? match[ 1 ].length : 0;  },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp