Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Jquery numeric validation

Posted on 2011-02-18
3
Medium Priority
?
818 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

647 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