简体   繁体   中英

Uncaught TypeError: $(…).formValidation is not a function JQUERY validation

This is my code for one field that I have in my form, for the unit_name.

$(document).ready(function() {
    $('#alwaysEnableButtonForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            unit_name: {
                validators: {
                    notEmpty: {
                        message: 'The task is required'
                    }
                }
            }
        }
    })
    .on('err.field.fv', function(e, data) {
        // $(e.target)  --> The field element
        // data.fv      --> The FormValidation instance
        // data.field   --> The field name
        // data.element --> The field element

        data.fv.disableSubmitButtons(false);
    })
    .on('success.field.fv', function(e, data) {
        // e, data parameters are the same as in err.field.fv event handler
        // Despite that the field is valid, by default, the submit button will be disabled if all the following conditions meet
        // - The submit button is clicked
        // - The form is invalid
        data.fv.disableSubmitButtons(false);
    });
});
</script>

** This is my JQUERY code for my form validation

Can anybody help me?

This is my error syntax:

Uncaught TypeError: $(...).formValidation is not a function
    at HTMLDocument.<anonymous> ((index):137)
    at j (jquery.js:3099)
    at Object.fireWith [as resolveWith] (jquery.js:3211)
    at Function.ready (jquery.js:3417)
    at HTMLDocument.I (jquery.js:3433)

This is my imports that I use to call the jquery validations..

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

This is my form that i use to show the validations information

<form name="#" method="POST" name="myForm" id="alwaysEnableButtonForm" >
                <fieldset>
                <legend>Insert unit:</legend>



    <div class="form-group">
        <label class="col-xs-3 control-label">Name unity: </label>
        <div class="col-xs-5">
            <input type="text" class="form-control" placeholder="name concept" name="unit_name" />
        </div>
    </div>

                <input type="hidden" name="state" value="insert">
                <div class="form-group">
        <div class="col-xs-5 col-xs-offset-3">
            <button type="submit" class="btn btn-default">Submit</button>
        </div>
    </div>
    </fieldset>
</form>

You are including the script from here: https://jqueryvalidation.org/

But your own script is trying to set up validation using the api commands of this: http://formvalidation.io/ , which is a different, commercial jQuery validation library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM