Code Direction for radio button error check

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bigjohnuk
    New Member
    • Feb 2007
    • 4

    #1

    Code Direction for radio button error check

    Hi Guys,

    I know to error check a drop down field called "Reason" i would use.

    if (document.HTML_ FORM.Reason.opt ions[0].selected == 1)
    errorMsg += "The field Reason is mandatory and has been left blank\n";

    and I know to check a text field I would use,

    if (!(document.HTM L_FORM.Reason.v alue))
    errorMsg += "The field Reason is mandatory and has been left blank\n";

    Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

    John
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by bigjohnuk
    Hi Guys,

    I know to error check a drop down field called "Reason" i would use.

    if (document.HTML_ FORM.Reason.opt ions[0].selected == 1)
    errorMsg += "The field Reason is mandatory and has been left blank\n";

    and I know to check a text field I would use,

    if (!(document.HTM L_FORM.Reason.v alue))
    errorMsg += "The field Reason is mandatory and has been left blank\n";

    Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

    John
    Java != Javascript

    Moved to Javascript forum

    Comment

    • abctech
      New Member
      • Dec 2006
      • 157

      #3
      Originally posted by bigjohnuk
      Hi Guys,

      I know to error check a drop down field called "Reason" i would use.

      if (document.HTML_ FORM.Reason.opt ions[0].selected == 1)
      errorMsg += "The field Reason is mandatory and has been left blank\n";

      and I know to check a text field I would use,

      if (!(document.HTM L_FORM.Reason.v alue))
      errorMsg += "The field Reason is mandatory and has been left blank\n";

      Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

      John
      this might be of help.

      Comment

      • bigjohnuk
        New Member
        • Feb 2007
        • 4

        #4
        Top draw I got there in the end. Thank you.

        var radIndex;
        var INOUTIndex = 2;

        for (radIndex = 0; radIndex < document.HTML_F ORM.Movement_IN OUT.length; radIndex++)
        {
        if (document.HTML_ FORM.Movement_I NOUT[radIndex].checked == false)
        errorMsg += "Please Select In or Out on your Movment\n";
        {
        INOUTIndex = radIndex;
        break;
        }
        }

        Comment

        • abctech
          New Member
          • Dec 2006
          • 157

          #5
          Originally posted by bigjohnuk
          Top draw I got there in the end. Thank you.

          var radIndex;
          var INOUTIndex = 2;

          for (radIndex = 0; radIndex < document.HTML_F ORM.Movement_IN OUT.length; radIndex++)
          {
          if (document.HTML_ FORM.Movement_I NOUT[radIndex].checked == false)
          errorMsg += "Please Select In or Out on your Movment\n";
          {
          INOUTIndex = radIndex;
          break;
          }
          }
          You are welcome, glad it helped.

          Comment

          Working...