Jquery numeric validation

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

LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ProculopsisConnect With a Mentor Commented:

Here is a simple alternative:

  <input onkeyup="this.value = this.value.replace( /\D/g, '' );" />
0
 
LAMASECommented:
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
 
erikTsomikSystem Architect, CF programmer Author Commented:
the answer was not complete
0
All Courses

From novice to tech pro — start learning today.