Validation Script

Results 1 to 2 of 2

Thread: Validation Script

  1. #1
    Join Date
    Dec 1969
    Posts
    50

    Default Validation Script

    I need the script to check if a radio button is checked. If it is check it then needs to make sure that a few other text boxes have been filled out. There is two choices for the radio button (yes, no) and the value for each is set to yes or no respectively.<BR><BR>Here is the code I have tried:<BR><BR>if(document.resume1.workedbefore.val ue == "yes"){<BR> if(document.resume1.txtnameused.value == ""){<BR> intEmpty = 13<BR> }<BR> if(document.resume1.txtposition.value == ""){<BR> intEmpty = 14<BR> }<BR> if(document.resume1.txtdivision.value == ""){<BR> intEmpty = 15<BR> }<BR> if(document.resume1.monleft.value == ""){<BR> intEmpty = 16<BR> }<BR> if(document.resume1.dayleft.value == ""){<BR> intEmpty = 17<BR> }<BR> if(document.resume1.yearleft.value == ""){<BR> intEmpty = 18<BR> }<BR> }<BR><BR>When I click submit on the form it just goes to the next page without even checking that radio button properly. Can anyone help?<BR><BR>Thanks in advance

  2. #2
    Join Date
    Dec 1969
    Posts
    96,118

    Default Use .checked, not .value

    Assuming that the first radio button of the pair is the "yes" one, then:<BR><BR>if ( document.resume1.workedbefore[0].checked )<BR>{<BR>...<BR><BR>*****************<BR><BR>*IF * you are writing an MSIE-only page, *THEN* you can use .value, but you have to be careful even then. For example, if you have &#060;INPUT Type=Radio Name="workedbefore" Value="Yes"&#062; then a check for == "yes" won&#039;t work, because "yes" != "Yes".<BR><BR>JS is very fussy. And JS with Netscape is even fussier.<BR><BR>

Posting Permissions

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