Solved

Jquery numeric validation

Posted on 2011-02-18
3
793 Views
Last Modified: 2012-05-11
I have a form filed where I need to validate the filled to allow user to enter only positive numbers. So NUMBERS Only. I am using jquery.numeric plugin however, it allow to to input the minus '-'. How can I prevent this from happening

0
Comment
Question by:erikTsomik
3 Comments
 
LVL 4

Expert Comment

by:LAMASE
ID: 34930745
Just add a mousedown/onchange/onblur event or whatever you want) and then

$('#inputfield').val(Math.abs($('#inputfield').val()));

Math.abs give the absolute value (without a sign).
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 500 total points
ID: 34931843

Here is a simple alternative:

  <input onkeyup="this.value = this.value.replace( /\D/g, '' );" />
0
 
LVL 19

Author Closing Comment

by:erikTsomik
ID: 35114294
the answer was not complete
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question