Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. TextBox Validation ( Not Allow these Characters )

TextBox Validation ( Not Allow these Characters )

Scheduled Pinned Locked Moved ASP.NET
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vishnukamath
    wrote on last edited by
    #1

    hi, i need to restrict given characters in Text Box , how can i restrict text-box (client side validation). Please suggest me better way. Thanks & Regards, Vishnu.

    A D T 3 Replies Last reply
    0
    • V vishnukamath

      hi, i need to restrict given characters in Text Box , how can i restrict text-box (client side validation). Please suggest me better way. Thanks & Regards, Vishnu.

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      vishnukamath wrote:

      how can i restrict text-box (client side validation).

      Given characters means ? number of char ? Are you looking for MAxLength ?

      Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net | Follow Me @ twitter Visit My Blog Abhijit's World of .NET

      V 1 Reply Last reply
      0
      • A Abhijit Jana

        vishnukamath wrote:

        how can i restrict text-box (client side validation).

        Given characters means ? number of char ? Are you looking for MAxLength ?

        Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net | Follow Me @ twitter Visit My Blog Abhijit's World of .NET

        V Offline
        V Offline
        vishnukamath
        wrote on last edited by
        #3

        hi, Not no of Characters and no maxlength ,characters mean (cc345,@sdrf)like the way.I need to restrict only these characters. Thanks and Regards, Vishnu.

        D 1 Reply Last reply
        0
        • V vishnukamath

          hi, Not no of Characters and no maxlength ,characters mean (cc345,@sdrf)like the way.I need to restrict only these characters. Thanks and Regards, Vishnu.

          D Offline
          D Offline
          David Mujica
          wrote on last edited by
          #4

          I believe the way you need to handle this is to write some javascript which will validate the field before returning to your application. The basic idea is something like:

          function validateMyStuff() {
          // I'm using this to validate that at least one radio button has been checked

          if (document.getElementById('<%=radPriceLow.ClientID%>').checked == false &&
          document.getElementById('<%=radPriceMid.ClientID%>').checked == false &&
          document.getElementById('<%=radPriceHigh.ClientID%>').checked == false) {
          alert("You must select a price to approve.");
          return false;
          }
          }

          My button on the web page is defined like this: Check the code for syntax errors, it may have gotten messed up when I did my copy & paste, but you should get the general idea. good luck :thumbsup:

          1 Reply Last reply
          0
          • V vishnukamath

            hi, i need to restrict given characters in Text Box , how can i restrict text-box (client side validation). Please suggest me better way. Thanks & Regards, Vishnu.

            D Offline
            D Offline
            daveyerwin
            wrote on last edited by
            #5

            this simple example will demonstate how to dis allow certain chars

            <html>
            <head>
            <script>
            restictIt = (function(){
            var args = arguments;
            return function(el){
            for(var i=args.length;i--;){
            if (el.value.indexOf(args[i]) != -1){
            el.value = el.value.substring(0,el.value.length-1);
            }
            }
            }
            })('a','b','c')// put disallowed chars here
            </script>
            </head>
            <body>

            <input type=text onkeyup="restictIt(this)">

            </body>

            </html>

            modified on Tuesday, September 14, 2010 12:38 PM

            1 Reply Last reply
            0
            • V vishnukamath

              hi, i need to restrict given characters in Text Box , how can i restrict text-box (client side validation). Please suggest me better way. Thanks & Regards, Vishnu.

              T Offline
              T Offline
              T M Gray
              wrote on last edited by
              #6

              Use the RegularExpressionValidator class.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups