I am making standard login panel in JSP, and it looks like this:

Please enter user name and password:
Username: [__________]
Password: [__________]
[submit] [reset]

Where underlines between brackets are edit boxes, and "submit" and "reset" are buttons.

It corresponds with this code:

<form action="main.jsp" method="POST" name="form">
    Użytkownik: <input type="text" name="username" value="" />
    <br /><br />
    Hasło: <input type="password" name="password" value="" />
    <br /><br />
    <input type="submit" name="loginOK" value="OK" onclick="
        <% if (request.getParameter("username")!="aaa") {  } %> 
    ">
    <input type="reset" name="loginReset" value="Czyść" />

I would be happy if when pressed "submit", user is provided to next page (main.jsp), but only if user is for example "aaa" (it doesn't matter). The problem is, that I don't know how to stop submitting to next page, if user is incorrect. I was looking for it in google, but I haven't found anything that helps me. Do you have any idea how to make it? Preferably in JSP, not javascirpt, which I know less.

JSP only has an effect after the submit, of course. JavaScript is your only choice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.