OT: simple html, js question

Zbox

Senior member
Aug 29, 2003
881
0
76
i'm creating this generic form, and don't want it to post unless two particular strings in the form match

what is the best way to implement this so that the user may not proceed unless the two strings match... is it possible to do this without js?

thanks ;)

-z
 

soni

Diamond Member
May 29, 2000
4,222
0
0
Implement a onSubmit function, which will catch all submit attemps even a pressed enter from user, and a click on button.

And no, not possible without code. But without js? Yes, you could use VB :p
 

ProviaFan

Lifer
Mar 17, 2001
14,993
1
0
I would do it server-side, in PHP, for two reasons: 1) Some users may have JS disabled, or may not be using a brower that supports VB, so bad data could slip through; and 2) I don't know JS. ;)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
jliechty: it sounds like he's doing both anyways. I'm sure whatever he's writing will check in on the server-side (sounds like passwords?) but he said
don't want it to post
which to me sounds like he's trying to save the client the time it takes to find out they made a mistake.

Now since I haven't actually contributed anything to the question so here's my little attempt (in case you haven't done it already :)):

<html>
<head>
<script type="text/javascript">
function checkSame() {
return (document.myForm.password.value == document.myForm.confirm.value);
}
</script>
<body>
<form name="myForm" onsubmit="return checkSame()">
<input type="password" name="password" />
<input type="password" name="confirm" />
</form>
</body>
</html>

Now I'm sure I didn't write that correctly the first time. Maybe someone can critique my effort?

Edit: fixing indentation