Solved

Cold fusion 9 cfinput validate = integer

Posted on 2011-09-13
5
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 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