Results 1 to 4 of 4

Thread: Validating 8 form fields with Javascript

  1. #1
    Join Date
    Jan 2014

    Validating 8 form fields with Javascript

    Hi all,

    I know this has probably been covered before ...

    I need to validate 8 seperate inputs in an HTML form using JS. I think I have got my regular expressions sorted I just need to bolt them to getElementById function. This is where I am having a brain freeze. Can anyone help me out, the first thing to validate is a 5 digit number between 0 and 99999 and not 00000


  2. #2
    Join Date
    Jan 2014
    Oh and I would like to alert to errors not with alert boxes but with a message on the page

  3. #3
    Join Date
    Mar 2007
    Perhaps a bit of code for others to look at can help...
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  4. #4
    Join Date
    Jan 2014
    I have got my number fields sorted I am struggling with date and time fields. I need to test a date in the format DD-MM-YYYY and a time in the format HH:MM:SS here is what I am trying

    /* validate Date Date */
    function validateDate() {
    var z = document.getElementById('Date').value;
    if (/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/) return true;

    else {
    document.getElementById('Date').value= "";
    setTimeout(document.getElementById('Date').focus, 50);
    return false;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles