Thread: Form Error

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Arkansas
    Posts
    2
    Rep Power
    0

    Form Error


    HELP!!

    This section is located on a form. If my users click the radio button, I want them to select option from the drop down menu.
    I need a javascript code that will generate an error message if the user only select one of the radio button and not the drop down menu option.



    Here's an example


    radio button Please add access to my account :
    -OR-
    radio button Please remove access to my account :

    drop down menu



    Here's my function

    Function addError(field, errDescription)
    If NOT BadFields.Exists(field) Then BadFields.Add field, errorclass
    If NOT BadText.Exists(field) Then BadText.Add field, "<br><span style=""color:#FF0000; font-size:11.5px; font-weight:bold;"">" & errDescription & "</span>"
    errs = true
    addError = errs
    End Function

    Here's the coding that I am using

    If Trim(Request.Form("fm_software")) <> "" AND Trim(Request.Form("fms")) = "" Then errs = addError("fms", "(Please choose whether to add or remove Financial Mangement Software)")
    End If


    Any suggestions of what I may need to use? Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Posts
    1,014
    Rep Power
    15
    Here's some sample code with a JavaScript check:
    Code:
    <script type="text/javascript">
    function validateForm(daForm) {
    	if (daForm.myradio.value != "" && daForm.myselect.value == "") {
    		alert ("Please make a selection!")
    		daForm.myselect.focus()
    		return false
    	}
    	return true
    }
    </script>
    </head>
    <body>
    <form onsubmit="return validateForm(this)" action="">
    <div>
    add_access: <input type="radio" name="myradio" value="add_access"><br>
    remove_access: <input type="radio" name="myradio" value="remove_access"><br>
    <select name="myselect">
    <option value="">Select an option:</option>
    <option value="somevalue1">somevalue1</option>
    <option value="somevalue2">somevalue2</option>
    <option value="somevalue3">somevalue3</option>
    </select>
    <input type="submit" value="send it now!">
    </div>
    </form>
    Hope this helps,
    Jeroen
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Arkansas
    Posts
    2
    Rep Power
    0
    Thanks! You guys are wonderful.

IMN logo majestic logo threadwatch logo seochat tools logo