Shashank Gupta
Shashank Gupta

Reputation: 3

I cannot validate ASP input using jQuery for the following Document

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

Upvotes: 0

Views: 60

Answers (1)

smr
smr

Reputation: 26

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>

Upvotes: 1

Related Questions