Skip navigation
yashpancholi
Currently Being Moderated

How to Create Text Field Which Accepts (Only Alphabates No Digits or Numbers)

Mar 10, 2012 11:47 AM

hey guys,

i just want know How to Create Text Field Which Accepts (Only Texts No Digits or Numbers)?

 

i want to insert validation that, field only accepts alphabates no number or digits are accepted!

 


thanks in advance!

 
Replies
  • Currently Being Moderated
    Mar 10, 2012 2:07 PM   in reply to yashpancholi

    For alphabetical characters only, use the following javascript on the validate event of the text field

     

    var r = new RegExp("^[a-z]*$");

    var result = r.test(this.rawValue);

     

    if (result == true)

        true;           

    else               

        false;  

     

    Also, set the Validation Script Message properties in the Object->Value Tab

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 7:00 AM   in reply to yashpancholi

    In Designer, click on the field you need to validate and open the script window, set the Show drop-down list to validate in the drop-down list and place the code inside the script window. Make sure the Language is Javascript and Run At is set to Client. If you cant see the script window goto Window->Script Editor Menu item.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 4:51 PM   in reply to yashpancholi

    Not sure if you are looking for an actual validation for the field (i.e. show an error and stop the user from moving to the next field) or just a filter in the field (i.e. no message and just stop characters being entered). From the original message i was assuming you were looking for a validation.

     

    If you want to use a message box validation and return to the field containing the error, use the following -

     

    On the exit event

     

    var r = new RegExp("^[a-z]*$");
    var result = r.test(this.rawValue);
     
    if ( result != true )
    {
        xfa.host.messageBox( "Enter alpha characters only" );
        xfa.host.setFocus( this );
    }
    

     

    If you are looking for a filter then, use the following on a change event of the field

     

    var r = new RegExp("^[a-z]*$");
    var result = r.test(xfa.event.change);
     
    if ( result != true )
    {
        xfa.event.change = "";
    }
    

     

    this will probably only work in pdf and some versions of reader had a bug with this so make sure you are on 10.1.2 to test this. see http://forums.adobe.com/thread/910259

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 12, 2012 10:58 AM   in reply to yashpancholi

    Try the second example in the previous message. That will disable any non-alpha input. Put it on the change event and remove any other event code.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 12, 2012 12:08 PM   in reply to yashpancholi

    The change event is fired each time a user interacts with an object using keystroke, paste, list selection, select/deselect check bos, or change radio button. The validate on the other hand only fires when the field losses when you tab to the next field for example

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 26, 2012 5:20 AM   in reply to yashpancholi

    It is only a sample of matching text. You do need to update the regular expression to match your requirements. So if you wish to allow spaces in the input, you would add this to the regular expression as follows

     

    var r = new RegExp("^[a-z' ']*$");
    

     

    also wouldnt do uppercase for example, so you would *** A-Z to the regexp ( i.e. [a-zA-Z' ']) and so on

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points