Solved

Cold fusion 9 cfinput validate = integer

Posted on 2011-09-13
5
397 Views
Last Modified: 2012-05-12
When I use validate= "integer" and required="yes" on one tag only the required option works. So if the user doesn't enter the field they are prompted to do so. But if they enter an invalid field, e.g. Aaa it goes through. If I take out the required="yes" then it validates that a value is intered but doesn't check if it is an integer.
0
Comment
Question by:kcjuliff
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 36532634
This works for me.  It may be a problem with your code. Can you post it?

<cfdump var="#FORM#">
<cfform name="f">
	<cfinput type="text" name="myField" required="true" validate="integer">
	<input type="submit">
</cfform>

Open in new window

0
 

Author Comment

by:kcjuliff
ID: 36532951
<Cfform action="opv.cfm" method="GET">
<table cellspacing="5" align="center">
	<tr><td><strong>Product code</strong></td><td><cfinput type="text" name="pc"   message = "Enter PC Number"
    validate = "integer"   maxlength="3" size="3" validateAt = "onBlur"></td></tr>
	<tr><td><strong>Model</strong></td><td><cfinput type="text" name="model" required = "yes"  size="6" message = "Enter model"  validateAt = "onBlur">
</td></tr>
	<tr><td><strong>PIC System</strong></td><td>
		<cfselect name="pic">
			<option value="">live</option>
			<option value="t">test</option>
			<option value="t2">test2</option>
		</cfselect>
	</td></tr>
	<tr><td colspan="2"><br></td></tr>
	<tr align="center"><td colspan="2"> <INPUT TYPE="submit" NAME="submitName"    style="width:250px; background-color:pink;"  onClick="this.value ='Processing' ; this.style.backgroundColor='#eee';   this.disabled=1; this.form.submit(); "  VALUE = "Click Me Once"  ></td></tr>
<table>
</cfform>

Open in new window

0
 

Author Comment

by:kcjuliff
ID: 36532968
Sorry, pasted  the working version. This is the non-working version.

<Cfform action="opv.cfm" method="GET">
<table cellspacing="5" align="center">
	<tr><td><strong>Product code</strong></td><td><cfinput type="text" name="pc"   message = "Enter PC Number"
    validate = "integer"  required="yes"  maxlength="3" size="3" validateAt = "onBlur"></td></tr>
	<tr><td><strong>Model</strong></td><td><cfinput type="text" name="model" required = "yes"  size="6" message = "Enter model"  validateAt = "onBlur">
</td></tr>
	<tr><td><strong>PIC System</strong></td><td>
		<cfselect name="pic">
			<option value="">live</option>
			<option value="t">test</option>
			<option value="t2">test2</option>
		</cfselect>
	</td></tr>
	<tr><td colspan="2"><br></td></tr>
	<tr align="center"><td colspan="2"> <INPUT TYPE="submit" NAME="submitName"    style="width:250px; background-color:pink;"  onClick="this.value ='Processing' ; this.style.backgroundColor='#eee';   this.disabled=1; this.form.submit(); "  VALUE = "Click Me Once"  ></td></tr>
<table>
</cfform>

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 250 total points
ID: 36533136
I think the inline javascript on your button is interfering. Try putting it in a function. Then call it onsubmit.

<script type="text/javascript">
	function submitForm() {
		var button = document.getElementById("submitButton");
 		button.value ='Processing'; 
 		button.style.backgroundColor='#eee';   
 		button.disabled=1; 
	}
</script>
<Cfform action="opv.cfm" method="GET" onsubmit="submitForm();">
<table cellspacing="5" align="center">
	<tr><td><strong>Product code</strong></td><td><cfinput type="text" name="pc"   message = "Enter PC Number"
    validate = "integer"  required="yes"  maxlength="3" size="3" validateAt = "onBlur"></td></tr>
	<tr><td><strong>Model</strong></td><td><cfinput type="text" name="model" required = "yes"  size="6" message = "Enter model"  validateAt = "onBlur">
</td></tr>
	<tr><td><strong>PIC System</strong></td><td>
		<cfselect name="pic">
			<option value="">live</option>
			<option value="t">test</option>
			<option value="t2">test2</option>
		</cfselect>
	</td></tr>
	<tr><td colspan="2"><br></td></tr>
	<tr align="center"><td colspan="2"> 
	<INPUT TYPE="submit" id="submitButton" NAME="submitName" VALUE = "Click Me Once">
</td></tr>
<table>


</cfform>

Open in new window

0
 

Author Closing Comment

by:kcjuliff
ID: 36533187
Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now