Results 1 to 3 of 3

Thread: JavaScript for enter only characters

  1. #1
    LewisClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default JavaScript for enter only characters

    Hi. I am working on one live project where I use as.net as front and SQL as a backend. Also I use JavaScript for validation. In my form one field is there for that field I want to write JavaScript for use enters only characters not numeric value. Any solution would be highly appreciated.

  2. #2
    WalkerCook is offline Senior Member
    Join Date
    Dec 2009
    Posts
    253
    Rep Power
    3

    Default

    The script that I have mentioned will definitely help you.

    Code:
    <script language="JavaScript" type="text/javascript">
    {
    
    var fname=document.Form1.getElementById("f_name").value;
    var chkok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'";
    var chkstr=document.Form1.fname.value;
    var allvalid=true;
    for(i=0;i
    {
    ch=chkstr.charAt(i);
    for(j=0;j
    if(ch==chkok.charAt(j));
    break;
    if(j==chkok.length)
    {
    allvalid=false;
    break;
    }
    }
    if(!allvalid)
    {
    alert("Please enter only Characters");
    document.Form1.fname.focus();
    return false; 
    }

  3. #3
    AdamsClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    247
    Rep Power
    3

    Default

    I suggest you to refer following example of JavaScript, which will give you something idea about the use of this script:

    Code:
    <SCRIPT language=Javascript type=”JavaScript/text”>
               function isNumberKey(evt)
          {
             var charCode = (evt.which) ? evt.which : event.keyCode
             if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
    
             return true;
          }

Similar Threads

  1. JavaScript for user enter only number.
    By allister fisher in forum Programming
    Replies: 2
    Last Post: 07-30-2010, 09:31 PM
  2. JavaScript for enter valid Email Id
    By AdamsClark in forum Programming
    Replies: 3
    Last Post: 04-29-2010, 01:23 PM
  3. JavaScript for enter only number.
    By BellWard in forum Programming
    Replies: 4
    Last Post: 04-29-2010, 01:12 PM
  4. Wildcard characters in SQL
    By Benny Kubelsky in forum Programming
    Replies: 1
    Last Post: 04-13-2010, 12:17 PM
  5. Cps (characters per second)
    By allster in forum General Networking
    Replies: 0
    Last Post: 03-20-2009, 05:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48