Solved

coldfusion.Ajax.submitForm disabling form field validation?

Posted on 2009-04-13
3
886 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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Website URL redirection 10 61
coldfusion, jQuery help 25 86
Why is my Splunk Web URL not working? 2 47
Best practices for sharing large amounts of data 9 51
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

21 Experts available now in Live!

Get 1:1 Help Now