|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
I can't figure out what problem I have. I put the exact syntax for cfinput as following: <cfinput type="text" name="city" size="30" required="yes" message="you have to enter a city"> and <cfselect query="display_price_range" name="min" display="price" value="price" required="yes" message="give me a min price."><option value="" selected>Minimum Price</option></cfselect> and <cfselect query="display_price_range" name="max" display="price" value="price" required="yes" message="give me a max price"><option value="" selected>Max Price</option></cfselect> When I tested it, I left all those fields blank. The page doesn't show me a little pop up window displaying the message. But instead it went to next page with an error page that who works with coldfusion often sees when there is an error. Does anyone know how to make it show the message and kind of stop going to next page until user enters something in the required fields? By the way, I created a table stores price values so that I can use it in list box. I made the price field in price_range as currency data type. However, when it showed online, each item -price, has 4 zeros after dot. Then I put 0 in the field said number after decimal places. It still did not work. Does anyone know why? |
|
#2
|
|||
|
|||
|
This code works for me, so I'm not sure what you are doing wrong:
<cfform action="page2.cfm" method="POST"> <cfinput type="text" name="city" size="30" required="yes" message="you have to enter a city"> <input type="submit" name="fff" id="fff" value="fff"> </cfform>
__________________
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 |
|
#3
|
|||
|
|||
|
I did as what you showed me. But it failed.
Thanks anyway. IF you know what caused the problem, please let me know. |
|
#4
|
|||
|
|||
|
I don't understand. You're telling me that you can copy the above code, paste it into a blank .cfm file, save it, and run it, and if you leave the select field blank and press submit, you do not get a Javascript alert that says "you must enter a city"?
|
|
#5
|
|||
|
|||
|
yes, exactly. That's why I don't understand.
|
|
#6
|
|||
|
|||
|
Can you paste the exact code that you are running so that I can see it? And what happens when you run it, do you get an error, or does nothing happen? Do other .cfm pages run correctly?
|
|
#7
|
|||
|
|||
|
<cfform action="next.cfm" method="post">
ID: <cfinput type="text" name="ID" validate="integer" required="yes" message="you have to give a number" > <input type="submit" name="s_mit" value="submit"> </cfform> Here is the code. If I didn't put anything in the form field, it will say next.cfm is not found. If I put something in there, then the page next.cfm runs fine. Thanks |
|
#8
|
|||
|
|||
|
Oh, I am sorry the error message is not "file not found" but it is something like this: missing operator [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ID='.
The error occurred in C:\Websites\next.cfm: line 11 9 : select ID 10 : from table_name 11 : where ID = #form.ID# 12 : </cfquery> 13 : <cfif validate_account.recordcount EQ 0> : : : : I used this ID form control to validate ID in the table. This is all I used it for. Thanks |
|
#9
|
|||
|
|||
|
I can take that code and paste it into an empty .cfm file and run it, and if I leave the field blank and press enter then I get a Javascript alert box telling me "you have to give a number".
So there is definitely something wrong on your end, either you have Javascript disabled in your browser or something else in the page is interfering in the execution of the Javascript. |
|
#10
|
|||
|
|||
|
Hi
Thank you again. I have a question, do I have to include this code in order for it to show the javascript? <script language="JavaScript" type="text/JavaScript"> <!-- function MM_popupMsg(msg) { //v1.0 alert(msg); } //--> </script> By the way, I discovered that I used the required and message attributes in several pages. Some of them works which means the javascript window shows the message. Some of them doesn't. I found out that the list box doesn't work, only the text box form control works. Do you have any comment? Last edited by sunbigsmile : May 26th, 2004 at 09:37 AM. |
|
#11
|
|||
|
|||
|
You don't have to put any Javascript in your page, CF generates it automatically.
I am not sure why some of the alerts work and some don't, but I am pretty sure that it must be some conflict on your page that is causing some of the alerts to fail. Confirm that you have different form field names (and corresponding form field id values) for each form element. Then try running only one or two form fields at a time until you determine which one or which combination is causing the problem. I should note that I'm not deeply familiar with using CFFORM as I hate it and prefer to write my own validation code. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > required and message attribute |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|