so my form is where you register you as a user. You type in 2 fields then press next and then 3 new fields come and then it runs the action="index.php?register=yes"
.
Now as you can see I highlighted "then press next" that's because maybe some users just press enter after typing in the last field, and then it runs the action. But if you click Next, it shows you the 3 new fields(fading them in with JavaScript) and I added a return false; so it doesn't run the action=""
in the form until the last button(on "page 2(with the 3 new fields")
Is there any way to do so you can "return false" if you just press enter(on your keyboard) like you can retur开发者_C百科n false when you click on the button so it doesn't run the action=""
?
Just replace
<input type="submit">
with
<input type="button">.
It will still look like a submit button, but it won't try to do the action.
You just attach a function() { return false; }"
on the onSubmit
event of your form when you display page 1 or 2 (you can even do a function to go to the next page), and you do a return true
when you're displaying page 3.
精彩评论