Javascript RegExp
function funRegComma(param){
var num = '' +param;
var reg = /(^[+-]?\d+)(\d{3})/;
while(reg.test(num)){
num = num.replace(reg,'$1' + ',' + '$2');
}
return num;
}
==== Password ====
비밀번호 체크하기 위한 RegExp
<code javascript>
var strongRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
| RegEx | Description |
^ | The password string will start this way |
| (?=.*[a-z]) | The string must contain at least 1 lowercase alphabetical character |
| (?=.*[A-Z]) | The string must contain at least 1 uppercase alphabetical character |
| (?=.*[0-9]) | The string must contain at least 1 numeric character |
(?=.[!@#\$%\^&]) | The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict |
| (?=.{8,}) | The string must be eight characters or longer |
| | |
전화번호
<h5:Action type="SCRIPT" name="checkPhone">
var regExpPhone = /^[0-9|-]+$/;
if( !regExpPhone.test($("#phone_no").val()) ){
var s = $("#phone_no").val().replace(/[^\d-]/g, '');
$("#phone_no").val(s);
}
</h5:Action>
<h5:TextInput id="phone_no" bindingColumn="phone_no" width="100px" maskText="PhoneNo" maxLength="20">
<h5:ElementEvents>
<h5:OnChangeEvent actionName="checkPhone"></h5:OnChangeEvent>
</h5:ElementEvents>
</h5:TextInput>
<h5:Action name="download" type="SCRIPT">
mySheet1.SetColHidden("detail",true);//type="Html" 숨기기.
var excelFileName = ""+ "선택근무제신청_"+getStdDate()+".xls";
var downcol = makeHiddenSkipCol( mySheet1 );
var params = { DownCols: downcol, FileName: excelFileName, SheetName: "Sheet", Merge:1, SheetDesign: 1 };
mySheet1.Down2Excel(params);
mySheet1.SetColHidden("detail",false);//type="Html" 보이기.
</h5:Action>
숫자의 콤마표현
function numberWithCommas(x) {
//sumVal = sumVal.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); //IE에서 오류
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}
시분표현
//시분포멧 (12:00) 체크
var timeFormat = /^([01][0-9]|2[0-3]):([0-5][0-9])$/;
//숫자 네자리(0000) 체크
var timeFormat2 = /^([01][0-9]|2[0-3])([0-5][0-9])$/;