Solved

coldfusion.Ajax.submitForm disabling form field validation?

Posted on 2009-04-13
3
896 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
[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
  • 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

632 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