jQuery MiniUI

 找回密码
 立即注册
查看: 2774|回复: 5
打印 上一主题 下一主题

文本框错误提示 [复制链接]

Rank: 1

跳转到指定楼层
楼主
发表于 2012-8-1 11:43:29 |只看该作者 |倒序浏览
文本框必须输入6个字符,如果不是的话在下面出来一行揭示,怎么做。

Rank: 9Rank: 9Rank: 9

沙发
发表于 2012-8-1 13:42:01 |只看该作者

Rank: 1

板凳
发表于 2012-8-1 13:58:32 |只看该作者
niko 发表于 2012-8-1 13:42
请参考:http://www.miniui.com/demo/#src=form/validLabel.html

<input style="width:160px;"  class="mini-textbox"  id="identityid" name="identityid" errorMode="none" onvalidation="onPwdValidation"
                   vtype="rangeChar:6" rangeCharErrorText="密码不能少于6个字符"/>
<script>

//////////////////////////////////////
        function updateError(e) {
            var control = e.sender;
            removeError(control);
            if (e.isValid == false) {                           
                addError(control, e.errorText);
            }
        }
        function focusInput(id) {
            var el = document.getElementById(id);
            if (el) el.focus();
        }
        function addError(control, errorText) {
            var textId = control.id + "$text";
            var errorId = control.uid + "$errorText";
            removeError(control);
            var jq = jQuery("#validGroup1");
            jq.append('<li id="' + errorId + '"><a href="javascript:focusInput(\''+textId+'\')">' + errorText + '</a></li>');
        }
        function removeError(control) {
            var errorId = control.uid + "$errorText";
            var el = document.getElementById(errorId);
            jQuery(el).remove();
        }

        //////////////////////////////////////////


        function onUserNameValidation(e) {     
            updateError(e);
        }
        function onPwdValidation(e) {
            updateError(e);
        }
</script>


不显示结果啊。

Rank: 9Rank: 9Rank: 9

地板
发表于 2012-8-1 15:35:56 |只看该作者
请参考:http://www.miniui.com/demo/#src=form/validLabel.html
你看错示例了把。

Rank: 1

5#
发表于 2012-8-2 09:18:58 |只看该作者
不管哪一个,它的意思是不少于6个字符,我想要的是必须为6个字符,不一样的啊。

Rank: 8Rank: 8

6#
发表于 2012-8-2 09:35:37 |只看该作者
heypity 发表于 2012-8-2 09:18
不管哪一个,它的意思是不少于6个字符,我想要的是必须为6个字符,不一样的啊。 ...

那就用validation事件自己写个验证必须为6个字符的的方法

Archiver|普加软件

GMT+8, 2024-9-20 06:45 , Processed in 1.044445 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部