Click to See Complete Forum and Search --> : Form Validation
bob_and_charlie
06-29-2003, 01:57 PM
I was wandering if there was a way for a form not to submit if a different name was inputted. Eg: If a person puts in an incorrect username and they click submit an alert box will appear and will say not a username but for many usernames
Take a look and see if this is what you need: http://forums.webdeveloper.com/showthread.php?s=&threadid=11656#post62544
Charles
06-29-2003, 05:26 PM
If you're only checking for a user name then you would do well to use an Object literal as an associative array of Booleans:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<style type="text/css">
<!--
input {display:block}
-->
</style>
<script type="text/javascript">
<!--
users = {fee:true, fie:true, foe:true, fum:true}
// -->
</script>
<form action="nextPage.html" onsubmit="if (!users[this.elements[0].value]) {alert('I don\'t believe that I\'ve had the pleasure of an introduction.'); return false}">
<div>
<label>User Name<input type="text"></label>
<input type="submit">
</div>
</form>
bob_and_charlie
07-01-2003, 04:16 AM
cheers. But i have signed up for a bravenet email form and i was wandering if there was any way to get the part of the script where it says
window.location.href = "URL"
to get it to use the action in the forms tag etc.
Yes, like this:
window.location.href = document.formname.action;
Charles
07-01-2003, 07:05 AM
Or, just use my example.