62,614
社区成员
发帖
与我相关
我的任务
分享
function checkPlanPrice() {
var planPrice = document.getElementById("planPrice").value;
var planPrice = trim(planPrice);
var regPlanPrice = /^[0-9]+[.0-9]*$/;
if(planPrice == null || planPrice =="") {
return true;
} else {
if(regPlanPrice.test(planPrice)) {
return true;
} else {
alert("PlanPrice 格式错误!");
document.getElementById("planPrice").value="";
document.getElementById("planPrice").focus();
return false;
}
}
}
String str = "4455|52.3|46";
String[] ss = str.split("[|]");
for (String s : ss) {
if (! s.matches("\\d+([.]\\d+)?")) {
System.out.printf("%s invalable\n", s);
} else {
System.out.printf("%s OK\n", s);
}
}
String[] ss = {"4455|52.3|46", "42.3|6|42", "556|52|42.6", "42", "42.3"};
for (String s : ss) {
if (! s.matches("\\d+([.]\\d+)?([|]\\d+([.]\\d+)?)*")) {
System.out.printf("%s invalable\n", s);
} else {
System.out.printf("%s OK\n", s);
}
}
String str = "123446.pdf|78593.pdf|56323.pdf";
String[] sa = str.split("[|]");
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy");
for (int i=0; i<sa.length; i++) {
//sa[i] = String.format("%td-%tm-%tY/%s", d, d, d, sa[i]);
sa[i] = sdf.format(d) + "/" + sa[i];
System.out.println(sa[i]);
}