Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter:以工具提示格式显示表单验证错误_Php_Tooltip_Codeigniter 3 - Fatal编程技术网

Php Codeigniter:以工具提示格式显示表单验证错误

Php Codeigniter:以工具提示格式显示表单验证错误,php,tooltip,codeigniter-3,Php,Tooltip,Codeigniter 3,我使用我的网站简单的登记表。我想在哪里以工具提示格式显示错误。可能吗 我尝试过一些解决方案,但不起作用 $(function () { $('input[name=name]').tooltip({ placement: "right", container:'#nameDiv', title: '<?php echo $error_title;?>', /*trigger: "hover"*/ }).tooltip('show'); }); $(函

我使用我的网站简单的登记表。我想在哪里以工具提示格式显示错误。可能吗

我尝试过一些解决方案,但不起作用

$(function () {
$('input[name=name]').tooltip({
    placement: "right",
    container:'#nameDiv',
    title: '<?php echo $error_title;?>',
    /*trigger: "hover"*/
}).tooltip('show');
});
$(函数(){
$('input[name=name]')。工具提示({
位置:“对”,
容器:“#nameDiv”,
标题:“”,
/*触发器:“悬停”*/
}).工具提示(“显示”);
});

听说过Jquery验证引擎吗

让我们试试看:


这是您可以做到的:

<form id="messageForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-xs-3 control-label">Message</label>
        <div class="col-xs-9">
            <textarea class="form-control" name="message" rows="5"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-3 control-label">Email address</label>
        <div class="col-xs-6">
            <input type="text" class="form-control" name="email" />
        </div>
    </div>

    <div class="form-group">
        <div class="col-xs-9 col-xs-offset-3">
            <button type="submit" class="btn btn-default">Send</button>
        </div>
    </div>
</form>

<script>
$(document).ready(function() {
    $('#messageForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            message: {
                // The messages for this field are shown as usual
                validators: {
                    notEmpty: {
                        message: 'The message is required'
                    },
                    stringLength: {
                        min: 20,
                        max: 500,
                        message: 'The message must be more than 20 and less than 500 characters long'
                    }
                }
            },
            email: {
                // Show the message in a tooltip
                err: 'tooltip',
                validators: {
                    notEmpty: {
                        message: 'The email address is required'
                    },
                    emailAddress: {
                        message: 'The email address is not valid'
                    }
                }
            }
        }
    });
});
</script>

消息
电子邮件地址
发送
$(文档).ready(函数(){
$('#messageForm').formValidation({
框架:“bootstrap”,
图标:{
有效:“glyphicon glyphicon ok”,
无效:“glyphicon glyphicon删除”,
正在验证:“glyphicon glyphicon刷新”
},
字段:{
信息:{
//此字段的消息与往常一样显示
验证器:{
注意:{
消息:“消息是必需的”
},
弦长:{
民:20,,
最高:500,
消息:“消息长度必须大于20个字符且小于500个字符”
}
}
},
电邮:{
//在工具提示中显示消息
错误:“工具提示”,
验证器:{
注意:{
消息:“需要电子邮件地址”
},
电子邮件地址:{
消息:“电子邮件地址无效”
}
}
}
}
});
});
参考链接:


上面的示例使用的是引导,您甚至可以使用Jquery/Javascript来实现这一点。

使用Jquery或javscript?请向我们展示您的演示如果有人禁用了javascript怎么办?这就是为什么我想让它进行服务器端检查,然后显示在工具提示中,尽管禁用了javascript,用户无法继续,因为正在进行服务器端检查