パスワードが一致しないことを確認するエラーメッセージが表示されますが、データベースに新しいリストが追加されます。スクリプトがフォームの送信を停止するようにするには、何をする必要がありますか?コーディングについての私の理解は非常に弱いです!
<script src="scripts/jquery.js" type="text/javascript">
jQuery(function(){
$("#submit").click(function(){
$(".error").hide();
var hasError = false;
var passwordVal = $("#password").val();
var checkVal = $("#repeatpassword").val();
if (passwordVal == '') {
$("#password").after('<span class="error">Please enter a password.</span>');
hasError = true;
} else if (checkVal == '') {
$("#repeatpassword").after('<span class="error">Please re-enter your password.</span>');
hasError = true;
} else if (passwordVal != checkVal ) {
$("#repeatpassword").after('<span class="error">Passwords do not match.</span>');
hasError = true;
}
if(hasError == true) {return false;}
});
});
</script>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">First name:</td>
<td><input type="text" name="firstname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last name:</td>
<td><input type="text" name="lastname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:*</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:*</td>
<td><input type="password" name="password" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Repeat Password:*</td>
<td><input type="password" name="repeatpassword" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Channel url:*</td>
<td><textarea name="channelurl" cols="50" rows="1"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Channel name:*</td>
<td><input type="text" name="chanelname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Description:</td>
<td><textarea name="description" cols="32" rows="6"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Video 1:* </td>
<td><input type="text" name="embedd1" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">What game is it?</td>
<td><input type="text" name="game1" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Video 2:</td>
<td><input type="text" name="Embedd2" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">What game is it?</td>
<td><input type="text" name="game2" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Keywords to describe and find your channel*</td>
<td><input type="text" name="keywords" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Channel Create"></td>
</tr>
</table>
<input type="hidden" name="chanelID" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>