-1

I am using jQuery validator and everything works fine. But now I have a requirement of using min and max value. But here is a problem.

Requirement

The user can input values from 60-600 or 0.

Code

<input type="number" value="0" max="600" min="60" class="form-control" id="interval" placeholder="Enter interval in seconds 0 or min. 60 - max 600" name="interval">

Problem

The issue in this is user can't input 0 value.

Sparky
  • 98,165
  • 25
  • 199
  • 285
Manoj Dhiman
  • 5,096
  • 6
  • 29
  • 68
  • Read the documentation for the plugin. You can write a custom method integrating the two requirements together. – Sparky Aug 14 '18 at 21:36

1 Answers1

-1

Try this https://codepen.io/iliyazelenko/pen/vaMgEQ

$(interval).on('input propertychange', () => {
  const val = +$(interval).val()
  
  if (val === 59)
    $(interval).val(0)
  else if (val < 59 && val !== 0)
    $(interval).val(60)
  else if (val - 1 === 0)
    $(interval).val(60)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="number" value="0" max="600" class="form-control" id="interval" placeholder="Enter interval in seconds 0 or min. 60 - max 600" name="interval" id="interval">