How To I Validate Form Using Client Side Javascript?


How do I validate a form i.e. text box of password box using client side javascript detecting this format? YYYY-MMM-DD-L? Y stands for Year, M -stands for the first three letters of any month, D – is a valid day and L is a letter. Please help thanks!

, , , , ,

  1. #1 by Armchair at June 18th, 2009

    If you’re going to check the PW against a database then you just need the bare essentials:
    strPW = document.form.txtPW.value;
    var regPW = / ^[d]{4}-[A-Za-z]{3}-[d]{2}-[A-Za-z]$ /;
    // then
    if (regPW.test(strPW) != true) {       // test is true if PW fits pattern

  2. #2 by sean_mcc at June 18th, 2009

    I was going to write one for you ;) . But I found the link below. Hope it helps. Youll want to modify the Regex something as follows
    /^([2ddd|1ddd])[.-/](0?[Jan|F…

(will not be published)
  1. No trackbacks yet.
Powered by Yahoo! Answers