May 30, 2006

判斷空白字元

為防止有人輸入空白字元,則可以撰寫成下列語法

<script language="javascript">
function Str_Trim(){
 if (document.frm_ABC.txtSubject.value.match(/[^\n^\s]/)==null )  
 {  
  alert('不可含有空白字元!!請重新輸入!!');  
  document.frm_ABC.txtSubject.focus();   
  return false;  
 } 
}
</script>