|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
Question i made a form that makes textboxes required and makes a popup appear if submit is hit and the textbox is empty, how do i do this same thing for drop-down menus?
Heres what im using for the textboxes. Code:
<cfinput
name="Name"
size="9"
required="Yes"
maxlength="50"
message="Please enter your name."
value="#SESSION.Alas.Name#">
Heres what i have for the drop-down Code:
<select name="Variable">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
-Alas ![]() |
|
#2
|
||||
|
||||
|
Ill take any ideas, "beggars can't be choosers"
![]() |
|
#3
|
|||
|
|||
|
You'll want to set a Javascript alert to fire onBlur(), which is when focus is removed from the select box.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
kiteless is right. You can only achieve this with JavaScript; since ColdFusion does not have, I think, the "required" atribute for drob down menus.
|
|
#5
|
|||
|
|||
|
Correct. This has been a pet peeve of mine for many years now. You can do it with server-side validation, just not client-side.
For server-side, try this for your dropdown: Code:
<select name="Variable"> <option selected value="">Choose One...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> Then include this anywhere between the form tags: Code:
<input type="hidden" name="Variable_required" value="A response to whatever is required."> |
|
#6
|
||||
|
||||
|
Why not use <cfeslect>? it gives you the required option and the meassage built into the object.
|
|
#7
|
|||
|
|||
|
please clarify
I dont think I totally understand the question. The way you have that drop-down written there must be an answer of yes or no. This forces an answer. Do you want to warn if it is no?
I would add "selected" to one of the answers. Code:
<select name="Variable" size="1"> <option value="Yes" selected>Yes</option> <option value="No">No</option> </select> |
|
#8
|
|||
|
|||
|
Quote:
Ebot's right. Check out http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags91.htm |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > How to make drop-down required |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|