Click here to Skip to main content
12,556,745 members (50,750 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET2
if i enter more than 2 digits it should not accept and textbox should surely contains % symbol...example:99%...should be in this format
Posted 2-Jan-13 6:53am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

<meta charset="UTF-8">
<title>ssn Checker</title>
<script type="text/javascript">
var Pattern= (\d+(\.\d+)?%);
function checkPercentage(Percentage){
    if (Pattern.test(Percentage)) {
        alert("VALID Percentage");
    } else {
        alert("INVALID Percentage");
    <form  önsubmit="return false;">
        <input type="text" name="Percentage" size="20">
        <input type="button" value="Check">

Second way, You can use Dotnet validation control(regular expression). Define your regex expression in the properties and Customize it as per your requirement.

Regular expression for your query:

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161026.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100