Re: [問題] javascript信用卡欄位輸入
看板Web_Design作者PHP5 (Powered by Zend Engine2)時間18年前 (2007/07/26 02:13)推噓0(0推 0噓 0→)留言0則, 0人參與討論串2/2 (看更多)
※ 引述《Gio99 (久)》之銘言:
: 大家好呀~^^"
: 不好意思 想請教一下一般的信用卡欄位
: 比如說是(4)(4)(4)(4) ()為欄位 4為字數
: 有無辦法做到直接貼上(ctrl+v)一段字 ex:123456789
: 然後可以貼進欄位裡為(1234)(5678)(9..)(...)
: 因為小弟愚昧實在想不出來@@a
: 希望有經驗的大德能幫忙解惑一下
: 感激不盡喔~~~
function autofill()
{
var myform = document.forms["form1"];
var num = myform.elements["c1"].value;
var num1 = num.substring(0,4);
var num2 = num.substring(4,8);
var num3 = num.substring(8,12);
var num4 = num.substring(12,16);
myform.elements["c1"].value = num1;
myform.elements["c2"].value = num2;
myform.elements["c3"].value = num3;
myform.elements["c4"].value = num4;
}
</script>
<form name="form1" method="post" action="">
<input name="c1" type="text" id="c1" onChange="autofill()">
<input name="c2" type="text" id="c2">
<input name="c3" type="text" id="c3">
<input name="c4" type="text" id="c4">
</form>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.245.58
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):