Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
164
rated 0 times [  165] [ 1]  / answers: 1 / hits: 12698  / 10 Years ago, fri, july 11, 2014, 12:00:00

I would like to add some inline javascript that alerts the user with a message AND then returns false, preventing the form from submitting.



onsubmit=return alert('You must be logged in to register'); return false


With the code above, I get the alert but the form still submits. I would like to retain the inline JS if possible. I searched around but couldn't find an inline example that follows this pattern. I know how to achieve this by executing a function with onsubmit, but again, would like to retain inline if possible.


More From » inline

 Answers
9

Try this :



<form onsubmit= alert('You must be logged in to register');return false;><input type=submit /></form>


Return stops the stack instruction.


[#43939] Thursday, July 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pranavrorys

Total Points: 466
Total Questions: 87
Total Answers: 115

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
pranavrorys questions
Fri, May 27, 22, 00:00, 2 Years ago
Thu, Oct 28, 21, 00:00, 3 Years ago
Sat, May 30, 20, 00:00, 4 Years ago
Fri, Dec 20, 19, 00:00, 5 Years ago
;