熟悉以如下示例的形式创建文本字段:-
Name :<input type="text" name="visitor" /><br /><br />
Email :<input type="text" name="visitormail" /><br /><br />
Phone :<input type="text" name="visitorphone"/><br /><br />
并验证与此类示例相同:-
$vname = $_GET["visitor"];
$vemail = $_GET["visitormail"];
$vphone = $_GET["visitorphone"];
// VALIDATION INTRODUCTION - THESE ARE THE FORM FIELDS THAT WE REQUIRED THE VISITOR TO FILL IN
if(empty($vname)
|| empty($vemail)
|| empty($vphone))
{
echo "<h2>Go Back and fill in all fields </h2>\n";
die ("Use the Go Back button !! ");
}
if(!$vemail == "" && (!strstr($vemail,"@") || !strstr($vemail,".")))
{
echo "<h2>Go Back and enter a valid E-mail Address</h2>\n";
die ("Use the Go Back button !!");
}
上面的脚本有效....看到这张图片!
我的问题是???
当使用 onfocus 文本字段创建表单时,如下例所示:-
<input type="text" name="visitor" value="NAME" size="23" onfocus="if (this.value == 'NAME') {this.value = '';}" onblur="if (this.value == '') {this.value = 'NAME';}">
....上述验证不再有效,因为文本字段中已经有一个条目!
上述验证是否可以用于新的 onfocus 情况?