最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

coldfusion - JavaScript on Form Submit - Stack Overflow

programmeradmin8浏览0评论

I am submitting a ColdFusion Form and I want to run some JavaScript to check field validation before I run my ColdFusion code to process the form as needed.

How can I do this? What do I do in JS to call my .cfm file after the form passes validation?

Thanks!

-Jason

I am submitting a ColdFusion Form and I want to run some JavaScript to check field validation before I run my ColdFusion code to process the form as needed.

How can I do this? What do I do in JS to call my .cfm file after the form passes validation?

Thanks!

-Jason

Share Improve this question asked Feb 2, 2009 at 16:56 Jason SlackJason Slack
Add a ment  | 

4 Answers 4

Reset to default 6

You need

<form name="myform" action="myserverscript.cfm" onsubmit="return validate()">

if you return true the form submits, false it doesn't

i hope you're doing the validation on the server side as well. never rely on just javascript to scrub your data.

JQuery - http://jquery./ validation addin for jquery - http://docs.jquery./Plugins/Validation

very simple to do tons of example on jquery.

You can attach a onclick event to your input button, for example:

<input type="submit" value="Submit" onClick="validate()">

Then the validate method will be responsible for checking form values. The validate method should return true if the form is valid, thus mitting the form submit. If it returns false the form is not submitted. This is how it works for HTML, JavaScript and forms.

In addition, the docs linked by mark should help you further.

发布评论

评论列表(0)

  1. 暂无评论