locked
Validation RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I am using BootStrap Validation . I want Text Box should not be empty & Only alphabets and Spaces are allowed

    <script type="text/javascript" charset="utf-8">
            $(document).ready(function () {
                $('#frmModal').bootstrapValidator({
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        txt_Code: {
                            validators: {
                                notEmpty: {
                                    message: 'The ID is required and cannot be empty'
                                }
                            }
                        },
                        txt_Description: {
                            validators: {
                                notEmpty: {
                                    message: 'cannot be empty'
                                }
                            }
                        }
    
                    }
                });
            });
        </script>

    Thanks

    Wednesday, August 22, 2018 5:21 AM

Answers

  • User1724605321 posted

    Hi JagjitSingh,

    I want Text Box should not be empty & Only alphabets and Spaces are allowed

    Then append the validation for alphabetical characters and spaces only :

         fields: {
                fullName: {
                    validators: {
                        regexp: {
                            regexp: /^[a-z\s]+$/i,
                            message: 'The full name can consist of alphabetical characters and spaces only'
                        }
                    }
                }
            }

    Reference : http://bootstrapvalidator.votintsev.ru/validators/regexp/ 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 23, 2018 2:06 AM