www.webdeveloper.com
Results 1 to 4 of 4

Thread: Form Validation Problem

  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Form Validation Problem

    Hi there. Would be extremely grateful if anyone can shed light on this for me. Sure it's the simplest of errors, but I'm a designer and am totally dyslexic with JavaScript!

    The function below is supposed to check if the radio option named 'method' with the value 'fax' is checked and if so, make sure that the input with the name 'vetfax' is filled in. It does nothing! Is it my syntax?

    Code:
     function DoCustomValidation()
    {
      var frm = document.forms["request"];
      if(frm.method.value == 'fax' && frm.vetfax.value == 'null')
      {
        sfm_show_error_msg('Please provide a fax number');
        return false;
      }
      else
      {
        return true;
      }
    }

  2. #2
    Join Date
    Oct 2003
    Location
    Andover, UK
    Posts
    947
    To check if a radio is checked:

    Code:
    document.getElementById('idOfRadio').checked // == true or false
    To check if a text field has a value in it:

    Code:
    document.getElementById('idOfRadio').value == "" // == true if empty, false if not

  3. #3
    Join Date
    Aug 2009
    Posts
    2
    Thank you very much!

  4. #4
    Join Date
    Aug 2009
    Posts
    48
    new thread opening isnt working.

    but can anyone inform me, how can we do two things using radio button once its clicked

    table.bgcolor='#ff0000
    <input type="radio" name="group1" value="A Chbat" onclick="javascript:document.sample.Number2.disabled=false">

    i want it to enable a textbox, plus color the tablerow.

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