Validating forms in Campaign Monitor
Campaign Monitor has posted a tutorial today on Making Certain Fields Required
You can see I've added
class="required"to the text fields I want to make compulsory, andclass="email required"in the case of the email address. I've also added anonsubmitparameter to the form tag, which will run our validation function when the submit button is clicked.
The example shows how to add JavaScript validation to your form fields from Campaign Monitor. A good tutorial, inspired by DOM Scripting. My only question is, they make it a point to use CSS classes for their hooks, yet add an inline onsubmit to handle the validation itself? Wouldn't it have been easier to wrap it all into one unobtrusive package?
2 Comments Add your comment
Mathew Patterson August 14th, 2008
Hi Nate,
Thanks for the link up. I left the onsubmit right there basically in consideration of my target audience for this post - it's people with very little experience in this area, so I just felt is was clearer to see what was happening with the onsubmit there.
It also makes it easier for them to see how to edit their form. You are right of course that it should be attached by the script when the page loads.
Nate Klaiber August 15th, 2008
Greetings Mathew,
That makes sense, I would have probably done the same. Sometimes you have to take some smaller steps. I think the way you did the fields validation was a good way for them to get a better understanding, and even a link to the resource (DOM Scripting).
Thanks for the explanation and for dropping by!