>> onvalidate is html property
Actually onValidate does actually call javascript.
Maybe this link will help:
livedocs.macromedia.com/co
livedocs.macromedia.com/co
Main Topics
Browse All TopicsAnyone know what the solution is for this? Whenever I set my cfform format to xml the onvalidate attribute does not make it to the final output, and I cannot use it. However if I change it to format="HTML" it then works as expected...
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry for the long delay.
I have a feeling that this may be a bug. If you look at:
http://livedocs.macromedia
It says that onValidate can be used in either HTML or XML forms but this clearly isn't the case since using xml forms and cfinput tags passes the onValidate through. However, using XML forms and cfinput tags with onValidate does not pass the onValidate attribute through and merely truncates it from the final output. I have tried 4 different skins, basic, basiccss, lightgray, and a custom skins that I created based off the original lightgray xsl. None of them seem to act any differently, they all truncate onValidate. I will post some code a little later when I get back to the office, I think the solution to this one however is to use qForms as I believe this to be a bug. I have stated such in the post above but have yet to see any reply to it.
I think you may be correct. The next question to really determine if it is in fact a bug is ignore your page. Create a very simple page with one cfinput and an onValidate...Nothing else. This will isolate the issue to xml and onValidate - and not other things going on on your page. If the problem is reproducible then it is a bug the you can report here:
http://www.macromedia.com/
If you include the steps you took in the simple test case then that helps Macromedia when fixing it.
This is straight out of the Coldfusion Documentation, the only difference is that I changed the form from html to xml. It does not work as expected, and of course, truncates the onValidate yet again. this is definitely a bug of some sort. Paste the following code into a cfm file. When you run this test it should ensure that the password is at least 8 characters long and that is has at least one uppercase, one lowercase, and one integer. This however, does not get checked at all because the onValidate attribute is truncated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html
<html>
<head>
<title>JavaScript Validation</title>
<!--- JavaScript used for validation. --->
<script>
<!--
// Regular expressions used for pattern matching.
var anUpperCase = /[A-Z]/;
var aLowerCase = /[a-z]/;
var aNumber = /[0-9]/;
/* The function specified by the onValidate attribute.
Tests for existence of at least one uppercase, lowercase, and numeric
character, and checks the length for a minimum.
A maximum length test is not needed because of the cfinput maxlength
attribute. */
function testpasswd(form, ctrl, value) {
if (value.length < 8 || value.search(anUpperCase) == -1 ||
value.search (anUpperCase) == -1 || value.search (aNumber) == -1)
{
return (false);
}
else
{
return (true);
}
}
//-->
</script>
</head>
<body>
<h2>JavaScript validation test</h2>
<!--- Form is submitted only if the password is valid. --->
<cfif IsDefined("Form.passwd1")>
<p>Your Password is valid.</p>
</cfif>
<p>Please enter your new password:</p>
<cfform name="UpdateForm" preservedata="Yes" format="xml" >
<!--- The onValidate attribute specifies the JavaScript validation
function. The message attribute is the message that appears
if the validation function returns False. --->
<cfinput type="password" name="passwd1" required="YES"
onValidate="testpasswd"
message="Your password must have 8-12 characters and include uppercase
and lowercase letters and at least one number."
size="13" maxlength="12" label="Password" />
<cfinput type="Submit" name="Submit" value=" Update... " />
</cfform>
</body>
</html>
Business Accounts
Answer for Membership
by: pinaldavePosted on 2005-08-16 at 23:42:45ID: 14689373
cfform works differently with the JS all the time. onvalidate is html property and works with html.
when XML or Flash format is specified it does not work properly. Not only that but I have noticed other many tags working differenly.
Also may be you can provide some code may be it I or some other expert might have work around or opinion. If nobody participate it means it is not easily possible.
Regards,
---Pinal