文字列オブジェクト 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <SCRIPT language="javascript" type="text/javascript"> // ********************************************************* // フォームのチェック // ********************************************************* function CheckData() { var str = document.getElementsByName("title")[0].value; var obj = document.getElementsByName("title")[0]; if ( Trim(str) == "" ) { alert( "タイトルを入力して下さい " ); return false; } if ( str.indexOf( '@' ) != -1 ) { alert( "正しい文字を入力して下さい " ); obj.focus(); obj.select(); return false; } return true; } function Trim( strValue ) { // 以下[]内の空白に見えるのは漢字スペース var regL = /^[ \s]+/; var regR = /[ \s]+$/; strValue = strValue.replace(regL,""); strValue = strValue.replace(regR,""); return strValue; }
<SCRIPT language="javascript" type="text/javascript"> // ********************************************************* // フォームのチェック // ********************************************************* function CheckData() { var str = document.getElementsByName("title")[0].value; var obj = document.getElementsByName("title")[0]; if ( Trim(str) == "" ) { alert( "タイトルを入力して下さい " ); return false; } if ( str.indexOf( '@' ) != -1 ) { alert( "正しい文字を入力して下さい " ); obj.focus(); obj.select(); return false; } return true; } function Trim( strValue ) { // 以下[]内の空白に見えるのは漢字スペース var regL = /^[ \s]+/; var regR = /[ \s]+$/; strValue = strValue.replace(regL,""); strValue = strValue.replace(regR,""); return strValue; }