Jquery validation message not working

前端 未结 2 1544
北恋
北恋 2021-01-17 02:41

I want to use validation messages on a form, but when I click on the botton nothing happens and I don\'t know why. I have struggled with this problem for a while now and nob

相关标签:
2条回答
  • 2021-01-17 02:49

    Your code is valid, but you forget to add the validation plugin, you added the css file, but no the js file, you can downlad it from http://jqueryvalidation.org/, and just add the line:

    <script src="js/jquery.validate.min.js"></script>

    I tried it, and its working

    0 讨论(0)
  • 2021-01-17 03:07

    You forgot to include the plugin in your code. I see jQuery, but the jQuery Validate plugin is missing...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Module Health Measurements</title>
    
            <!-- Load jQuery and the validate plugin -->
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
            <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
    

    However, your doctype does not allow you to use numbers to start your name and id values. It's not valid HTML unless you're using HTML5. See: https://stackoverflow.com/a/79022/594235

    Otherwise, your code, as you posted it, is working fine in this jsFiddle (jsFiddle uses HTML5, which is why it works here).

    http://jsfiddle.net/bpmtf/

    Can anyone please send me a link where I can download a proper .css stylesheet

    You'd write your own CSS to style the page elements & layout, otherwise, CSS has absolutely nothing to do with how this plugin operates.

    0 讨论(0)
提交回复
热议问题