Debbie,
I am using the jQuery validation plugin from this site ->
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
It requires jQuery 1.2.6 or higher. I am using 1.3.2 that can be downloaded from here ->
http://jquery.com/
Default download option for production is all you need.
Add the following in between your <head> </head> tags
<script language="javascript" type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="../js/jquery.validate.js"></script>
jQuery can be called from class= for each form element but I don't want to hard code all that into business_logic.php so all the jQuery form rules are in a separate js file.
<script language="javascript" type="text/javascript" src="../js/jquery.form.rules.js"></script>
An example of the form rules used for the update form you have helped me with would look something like this inside the jquery.form.rules.js file
$(document).ready(function() {
$("#update").validate({
rules: {
date_received: {
required: true,
date: true
},
received_by: {
required: true
}
},
messages: {
date_received: {
required: "Date received is required",
date: "Please enter a valid date."
},
received_by: {
required: "Received by is required"
}
}
});
})
Note: The
date_received and
received_by are element names in my form/database and are just an example.
The form does need an
id= which DaDaBIK already has in the function build_form section of business_logic.php
Example: $form .= "<form
id=\"dadabik_main_form\" name=\"contacts_form\" method=\"post\" action=\"".$action."?table_name=".urlencode($table_name)."&function=".$function;
But since this is used in all forms (insert,update,search etc..) you could run into trouble if you had the same form elements in an "update" form and a "search" form and validation was only needed for the "update" form. So what I did was add
IF statements for the different types of form types to change the id= as needed.
Example for form type
update:
if ( $form_type == "update" or $form_type == "ext_update") {
$form .= "<form
id=\"update\" name=\"contacts_form\" method=\"post\" action=\"".$action."?table_name=".urlencode($table_name)."&function=".$function;
This should get you started. jQuery can do a lot of cool stuff. I even found a jQuery pop calendar I may try out.
Let me know if you have any other questions
Post Edited (11-05-09 22:49)