var str=document.getElementById("你的Id")document.write(str.match(0|1))
是一串数字中只能有0和1还是一共就一位?
^[01]$
/^[0|1]*$/