0
head runat="server">
    <title></title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script type="text/javascript">
         $document.ready(function(){
    $("#Form1").validate({
        rules:{
          txtFname:{
                required:true,
                rangelength:[3,20],
            }
        },
        messages: {
            txtFname: "First Name Is Required",
        }
    })
            })//ready function close
        </script>
</head>
<body>
    <form id="Form1" runat="server" clientidmode="static">
        <asp:TextBox ID="txtFname" CssClass="form-control" runat="server"></asp:TextBox>
        <asp:Button CssClass="btn btn-primary" id="btnSubmit" runat="server" Text="Submit"/>
    </form>
</body>

I am trying to validate the txtFname Field in the form at row 1 in the modal but I am not able to.. I cant seem to figure out why. Can someone please help? I am using bootstrap v3

2
  • if you are using master page then this id will get changed, you can check this by inspect element in browser Commented Dec 25, 2016 at 4:39
  • I am not using a master page- just a blank Web form Commented Dec 25, 2016 at 5:33

1 Answer 1

1

Seems like a syntax issue (parenthesis, some extra colons and missing semicolons...etc)

try the following should work:

<script type="text/javascript">
     $(document).ready(function() {
         $("#Form1")
             .validate({
                 rules: {
                     txtFname: {
                         required: true,
                         rangelength: [3, 20]
                     }
                 },
                 messages: {
                     txtFname: "First Name Is Required"
                 }
             });
     })//ready function close
    </script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.