Hi,


I have a submit button in my JSP page. I also have drop down menus and text area in my form. Now my condition is like if drop down values or text area are null in this case if a user wants to submit he should get an alert message to fill the parameters first and it should stay on the same page.

Any suggestions ?

Thanks

Recommended Answers

All 3 Replies

After you click submit, the page will be passed to the server.

In your server side, do validation routines for your drop downs and text boxes. If there is invalid data, redirect to your original jsp page.

Hi,


I have a submit button in my JSP page. I also have drop down menus and text area in my form. Now my condition is like if drop down values or text area are null in this case if a user wants to submit he should get an alert message to fill the parameters first and it should stay on the same page.

Any suggestions ?

Thanks

Go for javascript validation. It will help you to restrict unnecessary server calls.

You will many suggestion and code snippet. Just do some searching in google.

Member Avatar for rakhi4110

You can go for javaScript..
Use onClick attribute for the submit button

For ex:

<form>
<input type="submit" value="submit" onClick="verify()" />
</form>
<script language="javaScript">
function verify()
{
 if(document.form_name.parameter_name.value=="")
 {
  alert('kindly enter all the details');
 }
}
</script>

alternatively instead of checking for each and every parameter you can also use elements... But i'm not very sure about the code snippet.. You can google for it...
Kindly let me know if this was helpful

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.