function checkDateFormat(formatStr,dateStr){
var pattern ="^"+formatStr+"$";
if(pattern.indexOf("yyyy")!=-1){
pattern=pattern.replace("yyyy","(\\d){4}");
}
else if(pattern.indexOf("yy")!=-1){
pattern=pattern.replace("yy","(\\d){2}");
}
if(pattern.indexOf("mm")!=-1){
pattern=pattern.replace("mm","(\\d){2}");
}
if(pattern.indexOf("MM")!=-1){
pattern=pattern.replace("MM","(\\d){2}");
}
if(pattern.indexOf("dd")!=-1){
pattern=pattern.replace("dd","(\\d){2}");
}
if(pattern.indexOf("HH")!=-1){
pattern=pattern.replace("HH","(\\d){2}");
}
else if(pattern.indexOf("hh")!=-1){
pattern=pattern.replace("hh","(\\d){2}");
}
if(pattern.indexOf("ss")!=-1){
pattern=pattern.replace("ss","(\\d){2}");
}
var regexDft=new RegExp(pattern);
if(dateStr.match(regexDft)==null) return false;
else return true;
}