Input field validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nvsuman519
    New Member
    • Nov 2008
    • 1

    Input field validation

    Hi,

    I am using following function to check for my input
    my input is like 0.00 i dont want to allow any specialcharacte rs. But it is perfectly validating the special symbols and characters.the problem is though I enter something like 45.00 it is giving message.Can anybody help me please its very urgent.

    Code:
    function check_basic(){
          var value = document.getElementById('curr_basic').value;
          var elem = document.getElementById('curr_basic');
                  var numexp = new RegExp('^[0-9]*\\.?[0-9]*$');
                  if(value!="")
                   {
                  if( elem.value.match(numexp))
                  {
                    return true;
                  }
                  else
                  {
                   alert("Enter Numeric values only");
                   elem.focus();
                   return false;
                  }
                 }
    
         }
    Last edited by acoder; Nov 19 '08, 10:03 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Are you sure? Your code works fine with 45.00. Post your HTML and the code that you call the function with.

    Comment

    Working...