validation problem

Results 1 to 2 of 2

Thread: validation problem

  1. #1
    kerry Guest

    Default validation problem

    whats the easiest way to check if there is no text only numbers in a text box

  2. #2
    Join Date
    Dec 1969

    Default RE: validation problem

    for that, you&#039d wanna use regular expressions. there&#039s a really good overview and reference in "JavaScript, the Definitive Guide" (from O&#039Reilley).<BR><BR>I haven&#039t tested it, but I&#039m pretty sure this is the code for what you want...<BR><BR>//*******************<BR>var test1 = "123456X789";<BR>var test2 = "1234567890";<BR><BR>var result1 = test1.match(/D/);<BR>var result2 = test2.match(/D/);<BR><BR>// /D/ says to look for a non-digit in the test string<BR><BR>//result1 is an array where result1[0] = &#039X&#039 (the mathching text)<BR>//and result1.index = 6 (the index of the matching text)<BR><BR>//result2 is equal to null, because there was no match<BR>//for a non-digit search<BR><BR>//*******************<BR><BR>hope this helps..

Posting Permissions

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