2 Replies Latest reply on Aug 31, 2010 9:51 PM by Manjula Vardhan

    Alpha validation

    Manjula Vardhan Level 1

      Hi,

       

      How to validate the user entered data whether it is alphabetic or numeric...

       

      Other than alphabets,an alert should be shown to the user.

       

      Regards,

       

      Manjula

        • 1. Re: Alpha validation
          Steve L Walker Level 5

          You can use numeric fields to force numeric data capture only. Alternatively, you can use regular expressions to force numeric or alpha data capture on text fields. The attached uses the following regular expressions:

           

           

          // form1.page1.tf-numeric-only::exit - (JavaScript, client)


           

           

          if (!(this.isNull)) {

            var tf = this.rawValue;

            // \D to match any character NOT in the range 0 - 9

            var regExp = /\D/;

            if (regExp.test(tf)) {

              xfa.host.messageBox("The field must be numeric.","Validation",1);

            }

          }


           

          // form1.page1.tf-alpha-only::exit - (JavaScript, client)


          if (!(this.isNull)) {

            var tf = this.rawValue;

            // \d to match any character in the range 0 - 9

            var regExp = /\d/;

            if (regExp.test(tf)) {

              xfa.host.messageBox("The field must be alpha.","Validation",1);

            }

          }

           

          Steve

          • 2. Re: Alpha validation
            Manjula Vardhan Level 1

            Thanks