Using CFFORM and Spry validation
So welcome to my 1st kinda useful post (I hope).
If anyone has tried using CFFORM and Spry (or any other AJAX framework I've tried so far) you have probably noticed that they do not play nice. Well fear not, there is a solution.
The magic is in calling onsubmit="return Spry.Widget.Form.validate(document.myform);" If you look at the source code of the outputted page you will see that Coldfusion places this line of javascript into it's own form checking function _CF_checkmyform, so you can still use all the CFFORM features if you like.
I find it neater to call a user defined javascript function rather, so I can place whatever other code I need to run in there too.
function validateForm() {
return Spry.Widget.Form.validate(document.myform);
}
</script>
<cfform name="myform" action="#CGI.SCRIPT_NAME#" method="post" onsubmit="return validateForm();">
When you try this out don't forget to take a look at what Coldfusion is actually outputting.
As I always say "(Almost) everything is possible but not everything is plausible" but as you can see, using CFFORM and Spry is both ;)

There are no comments for this entry.
[Add Comment]