js
if(!/^\d{7}$/.test(你的表单值)){
//...
}php
if( !preg_match("/^\d{7}$/", 你的表单值) ){
//...
}