Ramco Ramco

Ramco Ramco

  • 424
  • 3.4k
  • 491.3k

Validation message not working

Jul 20 2022 9:17 AM

Hi

 

<form id="form1" runat="server">

<div class="row">
                                <div class="col-12">
                                    <div class="input-group mb-4">
                                        <span class="input-group-text"><i class="fas fa-user-tie"></i></span>
                                        <asp:TextBox ID="txtVName" class="form-control alph" minlength="3" runat="server" placeholder="Enter your Name"></asp:TextBox>
                                    </div>
                                </div>
                            </div>       

                        <div class="col-md-6 col-12">
                                    <div class="input-group mb-4">
                                        <span class="input-group-text">
                                            <i class="fas fa-map-marker-alt"></i>
                                        </span>
                                        <asp:TextBox ID="txtVCity" class="form-control alph" minlength="3" runat="server" placeholder="Enter your City"></asp:TextBox>
                                    </div>
                                </div>

<script type="text/javascript">
        $(document).ready(function () {
            $('#form1').bootstrapValidator({
                message: 'This value is not valid', fields:
                {
                    txtVName: {
                        message: 'The ShortName is not valid',
                        validators: {
                            notEmpty: {
                                message: 'The ShortName is required and can\'t be empty'
                            },
                            stringLength: {
                                min: 3,
                                max: 50,
                                message: 'The ShortName must be more than 5 characters long'
                            }

                        }
                    },

                    txtVCity: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: 'The username is required and can\'t be empty'
                            },
                            stringLength: {
                                min: 1,
                                max: 30,
                                message: 'The username must be more than 6 and less than 30 characters long'
                            }
                        }
                    }
                }
            });
        });
    </script>

</form>

Thanks


Answers (1)