Problem in Validating txtfield

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhuriks
    New Member
    • Jun 2010
    • 149

    Problem in Validating txtfield

    hi,
    i had done validation in my project...my prob. is if i enter 'AM98' in txtfield it is taking....but it should not take..it has to take 'MA98'...here with i m sending the code...can anyone suggest the solution..its urgent

    Code:
    chkAct=/^[MA]{2}\d{2}$/;
    if (chkAct.test(form.act.value))
    {}
    else
    {
    alert('Invalid \"Activation Status\" Entry');
    return false;
    }
    Thanks in advance,
    madhu.
    Last edited by Dormilich; Jun 22 '10, 09:45 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    but you specified the letter portion to be: AM, MA, AA, MM. [MA]{2} means "two times a letter out of M or A" (keyword: character class)

    if you want MA exclusively, use
    Code:
    /^MA\d{2}$/

    Comment

    • madhuriks
      New Member
      • Jun 2010
      • 149

      #3
      Hi,
      thanks a lot...its working perfectly...

      Regards,
      madhu.

      Comment

      Working...