Solved

Cold fusion 9 cfinput validate = integer

Posted on 2011-09-13
5
400 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CFdocumnet font issue 5 43
Coldfusion CFMESSAGEBOX Passing Variables 6 118
Need to use URL Encode in CFDiv Tag ColdFusion, receiving error 2 63
cfspreadsheet 15 100
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 …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

809 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