I've been trying to use the jquery .validate() command on a form. I have the validation library appropriately linked as the help files on google say. Yet, when I press submit, the form submits and the validation script doesn't seem to run. This is my script:


Code:
<script type="text/javascript">
            $(document).ready(function(){
...
...
...
           $("#createpage").validate({
                                                        rules: {
                                                        site_title: "required",
                                                        site_tag: "required",
                                                        pages: "required",
                                                        color: "required",
                                                        standard: "required",
                                                        url_admin: { required "#admin:unchecked" },
                                                        user_admin: { required "#admin:unchecked" },
                                                        pass_admin: { required "#admin:unchecked" }
                                                        }
                                });
                             
              });
            </script>


When I open the Javascript console, no errors show up. What am I doing wrong?

ps: all of these identifiers (site_title, site_tag, etc) come from the "name" attribute of a part of the form.
bump
You don't have the valid and invalid callbacks, as per the readme. I recommend you add them.
**Looks at readme and is now more confused than before.
ACagliano wrote:
**Looks at readme and is now more confused than before.
Can you please phrase your post as an actual question or response to mine? I suggested that you add callbacks, and your response did little to indicate you had any idea what I meant.
KermMartian wrote:
ACagliano wrote:
**Looks at readme and is now more confused than before.
Can you please phrase your post as an actual question or response to mine? I suggested that you add callbacks, and your response did little to indicate you had any idea what I meant.


Thats the thing... i have no idea what you meant. lol

So far, I am under the understanding that the validate method takes rules as input. These rules get associated with input handlers based on the "name" attribute. Am I right?

Is a callback a function? What should it do? The sources I looked at addressed those as optional, unless I misinterpreted it.
ACagliano wrote:
Is a callback a function? What should it do? The sources I looked at addressed those as optional, unless I misinterpreted it.
Perhaps optional, but your original complaint was that nothing happened when the form got validated, which makes me think it was invalid. If you don't specify a callback when the form is invalid, I can't imagine you're going to get any sort of notification that the form is invalid. Yes, a callback is a function, and you really should know that already if you're using jQuery. It uses function arguments throughout, and callbacks are hardly limited to Javascript, either.
I'm familiar with the use of callback functions in other parts of jQuery. I was just unclear as to whether, in this instance, I needed to build one myself, or was there some default callback function that gets used.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement