Click here to Skip to main content
15,921,643 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Can any one help me in solving the problem
I need validation for amount in such a way that it should be maximum of 15 digits in that 12 digits numbers Ex:123456789101. and a dot(.) and after that 2 digits.

EX: 123456789101.00
Posted
Updated 8-Feb-11 21:37pm
v2

1 solution

Hi,
Try this example

XML
<html>
<head>
<script type="text/javascript">
    function demo(){
        var amount=document.getElementById('amount').value;
        var result=isValidAmount(amount);
        if(result==true){
            alert("Valid Amount");
        }else{
            alert("Invalid Amount");
        }

    }
    function isValidAmount(amount){
        var regEx=/^\d{1,13}.\d{2}$/;
        if(amount.search(regEx)==-1){
            return false;
        }else{
            return true;
        }
    }
</script>
</head>
<body>
    <input type="text" id="amount" />
    <input type="button" value="Test Validate" onclick="demo();"/>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900