1

表单验证不起作用,但相同的代码在 html 中运行,并且表单验证也有效我已经上传了所有静态资源,请建议我需要对代码进行哪些更改。1. 我已经成功上传了静态资源。2.所有文件路径正确。3.如果html标签到visualforce标签需要任何更改,请建议我

        <apex:stylesheet value="{!URLFOR($Resource.validation, 'valid/bootstrap.min.css')}"/>
        <apex:stylesheet value="{!URLFOR($Resource.validation, 'valid/formValidation.min.css')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/bootstrap.min.js')}"/>
        <apex:includeScript value="{!$Resource.bootstrapjs}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/bootstrap1.min.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/formValidation.min.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/jquery.min.js')}"/>



    </head>

    <body>
        <form id="basicBootstrapForm" class="form-horizontal">
            <div class="form-group">
                <label class="col-xs-3 control-label">Full name</label>
                <div class="col-xs-4">
                    <input type="text" class="form-control" name="firstName" placeholder="First name" />
                </div>
                                </div>



                                   </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-3 control-label" id="captchaOperation"></label>
                <div class="col-xs-4">
                    <input type="text" class="form-control" name="captcha" />
                </div>
            </div>



            <div class="form-group">
                <div class="col-xs-9 col-xs-offset-3">
                    <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Submit</button>
                </div>
            </div>
        </form>

        <script>
        $(document).ready(function() {
            // Generate a simple captcha
            function randomNumber(min, max) {
                return Math.floor(Math.random() * (max - min + 1) + min);
            }
            $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

            $('#basicBootstrapForm').formValidation({
                framework: 'bootstrap',
                icon: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    firstName: {
                        row: '.col-xs-4',
                        validators: {
                            notEmpty: {
                                message: 'The first name is required'
                            }
                        }
                    },

                 }   

            });
        });
        </script>
    </body>
</html>

4

1 回答 1

0

这是一个奇怪的问题。在 Jquery.js 之后的 HEAD 部分中使用 CDN 时,它得到了解决

<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.min.js"></script>
于 2018-11-06T13:43:40.540 回答