ValidationServlet.java 를 ValidationServlet.php 으로 :: 2009/09/16 20:26
<?php
/**
* Checks to see whether the argument is a valid date.
* A null date is considered invalid. This method
* used the default data formatter and lenient
* parsing.
*
* @param date a String representing the date to check
* @return message a String represnting the outcome of the check
*/
$formDate = $_GET["birthDate"];
// 넘어온 값을 바로 검증 시켜서 true, false 값을 넣자
$isPassed = validateDate($formDate);
$message = "i love you";
// xml 로 보내주자,
header('Content-Type: text/xml; charset=UTF-8'); // 이줄 ㅈㄴ 중요함.
echo ("<response>");
echo ("<passed>" . $isPassed . "</passed>");
echo ("<message>" . $message . "</message>");
echo ("</response>");
function validateDate($date){
$isValid = "false";
// check mm/dd/yyyy
if($date != ""){
if(preg_match("/[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}/",$date)){
$isValid = "true";
}
}
return $isValid;
}
?>




