title: Regular expression for decimal number accepting 0 to 4 digits but no characters
body: <p>I'm trying to devise a regular expression which will accept decimal number up to 4 digits.
  I have successfully done it when a user <strong>types</strong> it in a text box.
  Now, I'm trying to validate text box for <strong>paste</strong> operation.
  For that, I have written a <em>jquery</em> function</p>
  
  <pre><code> function pasteNumber() {
          var reNumber = /\d*\.\d{0,4}/;
          var theString = window.clipboardData.getData('Text');
  
          if (reNumber.test(theString) == false) {
              alert("You are trying to paste an invalid Number!")
              return;
          }
          event.srcElement.value = theString
          return;
      }
  </code></pre>
  
  <p>The regular expression which I have used is accepting a value like</p>
  
  <pre><code>44.aaaa
  </code></pre>
  
  <p>which it should not accept.
  Then I tried changing regular expression to </p>
  
  <pre><code>/\d*\.\d{1,4}/
  </code></pre>
  
  <p>Then, it started to accept values like</p>
  
  <pre><code>44.1aaa
  </code></pre>
  
  <p>I need help to write a regular expression which will accept values like</p>
  
  <pre><code>4.1
  421.11
  467.111
  438904.1111
  0.1
  </code></pre>
  
  <p>But not</p>
  
  <pre><code>1234.a
  489.a
  435.aaa
  412.1aaaa
  1567.11a
  </code></pre>
  
  <p>In short, there should be no characters.</p>
  
  <p>Any suggestions please?
  Thank you</p>