www.webdeveloper.com
Results 1 to 7 of 7

Thread: Min value

  1. #1
    Join Date
    Feb 2014
    Posts
    9

    Min value

    I'm a webdeveloper noob an I've been googling all around the web and I can't believe i can't find an answer that actually works. I need the minimun value of an input to be 1000 or minimum length 4 chars, doesn't really matter witch one. So if the input is 1000 or more, or blank it should be true, if under 1000 it should pop up an alert.
    Anyone can help? This shouldn't be too hard? Thanks in advance!

  2. #2
    Join Date
    Dec 2013
    Location
    Chandigarh
    Posts
    65
    Are you using any CMS to do this kind of task or any other framework. More elaborative question must be very good for the solution of this problem.
    In the practice of tolerance, one's enemy is the best teacher.

    Software and Web development by miraclegroup

  3. #3
    Join Date
    Feb 2014
    Posts
    9
    I'm using wordpress

  4. #4
    Join Date
    Oct 2013
    Posts
    420
    Try this:
    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>untitled</title>
    <script>
    	function check_min(el,min) {
         		if (el.value<min) {
             		alert("This entry must be a minimum of " + min + ".");
             		el.value='';
    			el.focus();
         		} 
     	}
    </script>
    </head>
    <body>
    <input type="number" min="1000" id="1" name="1" placeholder="1000" onchange="check_min(this,1000)"/> <label for="1">Minimum 1000</label><br>
    <input type="number" min="4321" id="2" name="2" placeholder="4321" onchange="check_min(this,4321)"/> <label for="2">Minimum 4321</label>
    <p>The function can be reused for any minimum by changing the appropriate numbers in the input tag.</p>
    </body>
    </html>
    How you go about getting that into Wordpress is another question.
    Also note that this doesn't check for non-number entries or characters.

  5. #5
    Join Date
    Feb 2014
    Posts
    9
    Thank you! This Works! And no problem getting that into wordpress! I thought that it would have alerted on submit, but this works as well!

  6. #6
    Join Date
    Oct 2013
    Posts
    420
    Quote Originally Posted by ImTheBurk View Post
    I thought that it would have alerted on submit
    I actually prefer to give users instant feedback, which this does. If you have a relatively long form and it alerts onsubmit, there's no context for the user to work with.

    Glad to help and good luck!

  7. #7
    Join Date
    Feb 2014
    Posts
    9
    I wonder if this is possible to do in jEditable?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles