EmailSurfer
asked on
Testing for required input in servlet?
Hello,
I am using javascript in my .jsp pages to check if the user entered data in the required fields.
I wondered if most developers also tested in servlet, incase javascript did not work? Or if this was not required anymore since javascript part of most modern browsers.
I am using this code in my jsp.
<form method="post" action="loginservlet" onsubmit="return validate(this);">
Could I test in the servlet if the onsubmit was successfull?
Thanks
I am using javascript in my .jsp pages to check if the user entered data in the required fields.
I wondered if most developers also tested in servlet, incase javascript did not work? Or if this was not required anymore since javascript part of most modern browsers.
I am using this code in my jsp.
<form method="post" action="loginservlet" onsubmit="return validate(this);">
Could I test in the servlet if the onsubmit was successfull?
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I completely (but respectfully) disagree ;-)
I agree with Tim ;-) , best to check in a servlet.. safer and secure.. No time to hack those javascript login ;-D
-Muj ;-)
-Muj ;-)
ASKER
Thanks
Could I ask finally,
In javascript are there any methods similar to java's indexOf, for example so I could check a email field contains a @ and . characters.
I would also further check for these in the servlet, just incase javascript is switched off.
Could I ask finally,
In javascript are there any methods similar to java's indexOf, for example so I could check a email field contains a @ and . characters.
I would also further check for these in the servlet, just incase javascript is switched off.
Sending request to server and getting back the result will take lot of time.
> incase javascript did not work?
this means that your script is not proper or a possible bug in it.
> Could I test in the servlet if the onsubmit was successfull?
you can validate in servlet also, but i would suggest u to write javascript for user input validation.