Solved

coldfusion.Ajax.submitForm disabling form field validation?

Posted on 2009-04-13
3
880 Views
Last Modified: 2013-12-24
I am using a simple <CFWINDOW> setup where I ssubmit a form using the ColdFusiion.ajax.submitForm function.  Everything works fine, but my cfform validation now is not working.  Does something in the <cfajaximport> wack something out with form validation?  How do I counter this?
body contents:
 

<cfwindow name="StatsWindow" center="true" closable="true"

                draggable="true" 

                modal="true"

                title="Please insert your stats"

                initshow="true" width="274" height="375"> 

	

      <cfform name="insertform"> ..........(form field, blah blah).....
 

......<input type="button" value="Submit" onclick="doInsertStats()" >
 
 
 

function called:
 

 // ajax submitForm fucntion to proxy cfc 'queries' and insert daily stats

         function doInsertStats() {

             

             ColdFusion.Ajax.submitForm('insertform', 'queries.cfc?method=insertstats',resultInsertHandler, insertErrorHandler);

             

     }

Open in new window

0
Comment
Question by:scripkilla
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24182962
when you submit a form/cfform using javascript, like you do, instead of clicking on a type="submit" button, CF does not automatically fire its built-in form validation scripts =  no built-in validation...

so, first question is: why do you have to use <input type="button"> instead of <input type="submit">?

second question is: are you aware of the fact that, by default, a CFFORM inside a cf ajax container (i.e. your cfwindow!) will submit into that container and will NOT refresh/reload the whole page?!
it looks to me like that IS the functionality you are after... if so, that IS the default behavior - you do not need to use ColdFusion.Ajax.submitForm() to submit your form into your cfwindow - just use a regular submit button and your cfform will be validated AND submitted into your cfwindow without refreshing the whole page!

of course, there may be a reason why you have to use <input type="button"> and can't use <input type="submit">, in which case, as i said above, cf's built-in form validation will not automatically work.
if this is your case - please let me know and i will post the code for you how to make it work.

Azadi
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24183061
PS:
forgot to mention that you would need to add an ACTION attribute to your <cfform> tag so that it submits to your cfc:
<cfform name="insertform" action="queries.cfc?method=insertstats">

now, after you change your button to type="submit", your cfform will submit to your cfc function without refreshing the whole page.

Azadi
0
 
LVL 1

Author Comment

by:scripkilla
ID: 24185844
wow, talk about over complicating things!  I did not realize cfwindow behaved as other ajax areas do in cf.  I just wished I hadn't wasted so much time getting it to work the long way.  I was able to workaround using javascript, but it was garbage.  Thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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