Using jquery form and validation plugins together
Hi
I've got jquery form working perfectly, but have no idea what code to add to include validate on the same form.
Here's my script:
- <script type="text/javascript" src="/js/jquery-1.3.2.js"></script>
- <script type="text/javascript" src="/jquery.form.js"></script>
- <script type="text/javascript" src="/jquery.validate.js"></script>
-
- <script type="text/javascript">
-
- $(document).ready(function() {
- $('.spinner').hide();
- var options = {
- target: '#output1', // target element(s) to be updated with server response
- beforeSubmit: showRequest, // pre-submit callback
- success: showResponse // post-submit callback
-
- };
-
- $('#myform').ajaxForm(options);
- });
-
- function showRequest(formData, jqForm, options) {
- var queryString = $.param(formData);
-
- $('#test_null_submit').hide();
- $('.sub_spinner').show();
- return true;
- }
-
- function showResponse(responseText, statusText) {
- $('.spinner').hide();
- $('#pfh').hide();
- }
- </script>
and a part of my form:
- <form class="contrib" name="contact" id="myform" method="post" action="process_form.asp">
- <fieldset>
- <label for="company" id="company_label">Company name *</label>
- <input type="text" name="company" id="company" class="input3 required" size="25" />
- <label for="address1" id="address1_label">Address</label>
- <input type="text" name="address1" id="address1" class="input3" size="25" />
- <input type="submit" name="submit" class="button" value="Submit" />
- </fieldset>
- </form>
The idea is to use the validate plugin to only submit if a company name is added. I'm guessing I need to add something to the ShowRequest" function which is called BeforeSubmit - but I can't work out what to do.
Any help would be greatly appreciated.
Many thanks