Solved

Cold fusion 9 cfinput validate = integer

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

16 Experts available now in Live!

Get 1:1 Help Now