开发者

validation of textbox

开发者 https://www.devze.com 2023-02-27 09:58 出处:网络
how do i validate the address and zip开发者_JAVA技巧 field which is entered in textbox in jsp???from a quick google (which you could have done ;) ) it seems you want something like

how do i validate the address and zip开发者_JAVA技巧 field which is entered in textbox in jsp???


from a quick google (which you could have done ;) ) it seems you want something like

<%
if(
    request.getParameter("your_address_field") == null || 
    request.getParameter("your_zip_field") == null || 
    request.getParameter("your_address_field").equals("") ||
    request.getParameter("your_zip_field").equals(""))
 {%>
    Error: form validation failed...
 <% } %>

This is server side validation. however, you need to know as Harry Joy states, there is also benefit in doing this validation on the client side via Javascript. That way the user experience can be improved as the form is not being submitted to the server. One issue to be aware of though, is you then rely on the client browser which could have Javascript disabled etc

Here is a good SO thread on Client side vs server side. I suggest you read it :)

I hope that helps

0

精彩评论

暂无评论...
验证码 换一张
取 消