Wednesday, 17 July 2013

Validating number of characters before and after decimal point using javascript

  function validatemaxAmt(sender, evt)
{
              var splitValue = sender.value.split(".", 2);

        
                  if(splitValue[0] != null)
                 {
                    if(splitValue[0].length < 7)
                    {
                       // alert("Correct format.");
                        return true; // allow postback (if applicable)
                    }
                    else
                    {
                        alert("Incorrect number of decimal digits.");
                        sender.value="0";
                        sender.focus();
                        return false; // disallow postback (if applicable)
              
                    }
                }
}

No comments:

Post a Comment