top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can I validate numbers range, using autoNumeric() in jQuery?

+3 votes

I am trying to control input field using jQuery previously I had only numbers and could use $(this).autoNumeric(), now I have come around where it is required to change the input field in form of 'Numbers dash Numbers'.
i.e:- 1.343-45.643

Is there anything similar to autoNumeric which can do my work apart from writing my own regex and jquery method.

posted Dec 26, 2014 by Atiqur Rahman

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Before commenting anything, let me understand the question fully.

1. This question is about the jQuery validation if input integer is within given range or not.
2. Second part of the question is not clear to me, would you like to describe more...
Sir, Second part mean, to achieve this work(first part) we can write a jquery method where using regular expression we can validate input fromat( 1.423-6.253). It has flaws like it allows to enter any character and then validate, which i don't want. I just want that input box only allows numbers and dash.
   If it were only numbers(1.424) then we could validate using autoNumeric() function without above described flaws.

1 Answer

+1 vote

Hi,I think Jquery don't have built method for that.Better you go for your own regex.I hope this /^[0-9.-]+$/ regex will help you.

answer Dec 29, 2014 by Pankaj Deshmukh
As i said this has flaws like it allows all the characters to get entered into InputBox then validate. Here I just want that it should allows only numbers and dash to get entered into InputBox. Any leads on this will be appreciated.
/^[0-9.-]+$/ This regex will help you right.This will allow only numbers,dash and dot.
Use to following link get the regex for the range (you can enable verbose) to know step by step. Though its not taking the flowing point but building that over it should not be difficult.
Similar Questions
0 votes

I tried the following code.Both onpaste() and Oncopy() will trigger when user trying to copy or paste.

But my problem is while copying something window.getSelection() not working.

Window.getSelection() is used to get the selected data.

I mean before copying something user need to select some values.So,using this window.getselection() we will get the value what they are selected.

Here, my problem is window.getselection() will work in oncopy but not working in onpaste.

Check the below examples and help me to solve the problem.

Also ,is there any alternative method also please let me know.I also tried window.clipboardData.But not getting the solution for this.

<!doctype html>
    textarea {
        border:2px solid #999;

<script src=""></script>

    <script type="text/javascript">

        function OnPaste () {                                                                       
            var selection = window.getSelection();          
        function OnCopy() {         
            var selection = window.getSelection();

// Call the OnCopy function while user trying to copy 
document.oncopy = OnCopy;

// Call the OnPaste function while user trying to Paste
document.onpaste = OnPaste;

    Select some text, copy it to the clipboard and try to paste it to the following fields:
    <br /><br />
    <textarea size="40" value="Copy and Paste operation is enabled">
+5 votes

I need disable all refresh events


  1. F5,
  2. Mouse right click option (refresh/reload),
  3. CTRL+R,
  4. Menu bar -> view -> refresh and
  5. URL refresh/reload button

How to disable these all events by using javascript...

Advance thanks....

0 votes

Please give the example for both.