You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhky/web/css/postcodeFormat.htc

39 lines
913 B

<public:component>
<public:attach event="onblur" onevent="itemOnBlur()" />
<public:attach event="onkeypress" onevent="keypress()" />
<public:attach event="onbeforepaste" onevent="beforePaste()" />
<public:method name="validate">
<script language="javascript">
function validate() {
if (element.value.length==0) return true;
var pat = /(^[0-9]{6}$)/;
var ret = pat.exec(element.value);
if(!ret) {
alert("错误的邮政编码格式!");
element.value="";
element.focus();
return false;
}
return true;
}
function itemOnBlur(){
validate();
}
function keypress() {
if ( !((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
window.event.keyCode = 0 ;
}
//element.value = element.value.replace(/[^\d]/g,'');
}
function beforePaste() {
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''));
}
</script>
</public:component>