Solved

coldfusion.Ajax.submitForm disabling form field validation?

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion: Two dynamic depending drop down 12 57
How code a 301 redirect for folder files -> 1 file 2 80
Company website 6 66
AJAx/JQuery/JSON Error 3 39
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…

710 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