Solved

Cold fusion 9 cfinput validate = integer

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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

628 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