gpt4 book ai didi

javascript - 如何在手机验证场景中使用 dojo.destroy 和 dojo.create?

转载 作者:行者123 更新时间:2023-11-28 10:25:51 25 4
gpt4 key购买 nike

我有一个问题,我有一个连接到 dojo 下拉小部件的电话输入字段。您可以选择美国电话类型或国际电话类型。如果您选择“美国”类型,则只能在输入字段中输入 10 个字符。如果选择国际类型,则可以在输入字段中输入 15 个字符。这在 Firefox 和 Internet Explorer 8 中可以正常工作,但在 Internet Explorer 7 中不能正常工作。

这是html代码:

<input id="tPhone" type="text" name="tPhone" class="isCompleted phone-number" tabindex="0" maxlength="10" rel="i13"/>

我想如果我动态地改变或销毁 dom 节点并根据用户所做的选择替换它,我就可以让它在 dojo 中正常工作。我怎样才能用dojo做到这一点?这是我现在拥有的道场代码:

this.phoneTypeDrop = new widget.StyledDropdown(dojo.byId("sPhoneType"),function(){
if(_this.phoneTypeDrop.getSelectedIndex() == 0){
Phone.pnField.regEx = Validation.regExps.phone;
dojo.attr(dojo.byId(Phone.pnField.id),"maxlength", 10);
}else{
Phone.pnField.regEx = Validation.regExps.phoneInternational;
dojo.attr(dojo.byId(Phone.pnField.id),"maxlength", 15);
}
},true,64);

最佳答案

我修好了。 IE 可能会很痛苦。我在同事的帮助下进行了检查,发现 IE7 的 maxlegnth 语法与其他浏览器不同。它使用 maxLegnth 大写“L”。所以代码现在看起来像这样:

this.phoneTypeDrop = new widget.StyledDropdown(dojo.byId("sPhoneType"),function(){
if(_this.phoneTypeDrop.getSelectedIndex() == 0){
Phone.pnField.regEx = Validation.regExps.phone;
dojo.attr(dojo.byId(Phone.pnField.id),"maxLength", 10);
}else{
Phone.pnField.regEx = Validation.regExps.phoneInternational;
dojo.attr(dojo.byId(Phone.pnField.id),"maxLength", 15);
}
},true,64);

关于javascript - 如何在手机验证场景中使用 dojo.destroy 和 dojo.create?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4327656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com