How to validate the input field values before leaving the JSP page?

A

Arnold Peters

I set up a jsp page (say: first.jsp) with a couple of input-/entryfields in a form.
After the user entered some values he clicks on the submit button.
Normally (if all values are acceptable) the user should be forwarded to the next page (next.jsp).
If (and only then) the values are wrong the user should stay on the current page and some
error messages should appear at the top of current jsp.

Thus what I need is a code execution BEFORE leaving the current page and not (only) when the
page is created.

How do I implement this with JavaServerPages (under JBoss) ?
Unfortuantely there is no command like

<form action="if (validate(this.formdata)==true) next.jsp else first.jsp">

Arnold
 
T

Tomer Ben-David

I set up a jsp page (say: first.jsp) with a couple of input-/entryfields in a form.
After the user entered some values he clicks on the submit button.
Normally (if all values are acceptable) the user should be forwarded to the next page (next.jsp).
If (and only then) the values are wrong the user should stay on the current page and some
error messages should appear at the top of current jsp.

Thus what I need is a code execution BEFORE leaving the current page and not (only) when the
page is created.

How do I implement this with JavaServerPages (under JBoss) ?
Unfortuantely there is no command like

<form action="if (validate(this.formdata)==true) next.jsp else first.jsp">

Arnold

perhaps something like this

<form onSubmit="return somevalidation(this)">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top