Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript restrict number to range

// Restricts number from 20 to 1 
// if number > 20 returns 20
// if number < 1 returns 1
// else returns number
var number = Math.min(Math.max(parseInt(number), 1), 20);
Source by www.google.com #
 
PREVIOUS NEXT
Tagged: #javascript #restrict #number #range
ADD COMMENT
Topic
Name
5+3 =