108 lines
2.9 KiB
HTML
108 lines
2.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Test for Manuel Lemos' PHP form class using a custom validation plug-in input</title>
|
|
<style type="text/css"><!--
|
|
.invalid { border-color: #ff0000; background-color: #ffcccc; }
|
|
// --></style>
|
|
</head>
|
|
<body onload="document.forms['custom_validation_form']['first'].focus()" bgcolor="#cccccc">
|
|
<center><h1>Test for Manuel Lemos' PHP form class using a custom validation plug-in input</h1></center>
|
|
<hr />
|
|
<form method="post" action="" name="custom_validation_form" onsubmit="return ValidateForm(this)">
|
|
<script type="text/javascript" defer="defer">
|
|
<!--
|
|
function ValidationError(form, Invalid, error_message, focus)
|
|
{
|
|
alert(error_message)
|
|
if(form[focus].focus)
|
|
form[focus].focus()
|
|
}
|
|
|
|
function ValidateForm(theform)
|
|
{
|
|
var e
|
|
r=theform['first']
|
|
r.className=''
|
|
r=theform['second']
|
|
r.className=''
|
|
if(theform['first'].value=='')
|
|
{
|
|
r=theform['first']
|
|
r.className='invalid'
|
|
e='It was not specified a valid first name.'
|
|
ValidationError(theform, {'first': e }, e, 'first')
|
|
return false
|
|
}
|
|
if(theform['second'].value=='')
|
|
{
|
|
r=theform['second']
|
|
r.className='invalid'
|
|
e='It was not specified a valid second name.'
|
|
ValidationError(theform, {'second': e }, e, 'second')
|
|
return false
|
|
}
|
|
first=theform['first'].value
|
|
second=theform['second'].value
|
|
if(second.indexOf(first) != -1)
|
|
{
|
|
r=theform['first']
|
|
r.className='invalid'
|
|
e='The first name is contained in the second name.'
|
|
ValidationError(theform, {'first': e }, e, 'first')
|
|
return false
|
|
}
|
|
if(first.indexOf(second) != -1)
|
|
{
|
|
r=theform['second']
|
|
r.className='invalid'
|
|
e='The second name is contained in the first name.'
|
|
ValidationError(theform, {'second': e }, e, 'second')
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
// -->
|
|
</script>
|
|
<noscript>
|
|
<div style="display: none"><!-- dummy comment for user agents without Javascript support enabled --></div>
|
|
</noscript>
|
|
<div id="feedback" style="text-align: center;"></div>
|
|
<br />
|
|
<div id="wholeform">
|
|
<center><table summary="Form table" border="1" bgcolor="#c0c0c0" cellpadding="2" cellspacing="1">
|
|
<tr>
|
|
<td bgcolor="#000080" style="border-style: none;"><font color="#ffffff"><b>Form custom validation plug-in test</b></font></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td style="border-style: none;"><center><table summary="Input fields table">
|
|
|
|
<tr>
|
|
<th align="right"><label for="first" accesskey="F"><u>F</u>irst name</label>:</th>
|
|
<td><input type="text" name="first" id="first" accesskey="F" /></td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th align="right"><label for="second" accesskey="S"><u>S</u>econd name</label>:</th>
|
|
<td><input type="text" name="second" id="second" accesskey="S" /></td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td colspan="3" align="center"><hr /></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td colspan="3" align="center"><input type="submit" name="doit" value="Submit" onclick="sub_form='' ; return true" /></td>
|
|
</tr>
|
|
|
|
</table></center>
|
|
</td>
|
|
</tr>
|
|
</table></center>
|
|
</div></form>
|
|
<hr />
|
|
</body>
|
|
</html>
|