Solved

coldfusion.Ajax.submitForm disabling form field validation?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need some regex help 15 29
alert before form submission 6 41
Auto refresh part of an MVC5 View 7 94
Restore of mysql database from .SQL file - using Coldfusion 5 37
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

823 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