Client side and server side validations compatibility

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajos
    Contributor
    • Aug 2007
    • 283

    Client side and server side validations compatibility

    Hi friends,
    I guess i am asking this question in the right forum.
    I have a jsp page where i have a javascript date picker function enabled. This part is working perfectly, but when i tried to do a server side validation for empty fields, it failed to fire up(i.e the server side error/empty field message). So my question is can a javascript validation and a server side validation coexist(using struts/java) or am i making some silly mistake here?.Thanks
    regards,
    ajos :)
  • ajos
    Contributor
    • Aug 2007
    • 283

    #2
    Originally posted by ajos
    Hi friends,
    I guess i am asking this question in the right forum.
    I have a jsp page where i have a javascript date picker function enabled. This part is working perfectly, but when i tried to do a server side validation for empty fields, it failed to fire up(i.e the server side error/empty field message). So my question is can a javascript validation and a server side validation coexist(using struts/java) or am i making some silly mistake here?.Thanks
    regards,
    ajos :)
    Ok i got the client side script working, but i've got myself into a twisted situation here. My jsp flow goes like--> The user clicks a link, some of the values of that link is passed as hidden parameters to the next jsp page. The hidden parameters are getting displayed in the 2nd jsp page, but when i leave the page blank and click on submit, the value(which i got as hidden) gets null and even my javascript calender gets deactivated(??? ), eventually showing the validation message. Why does this happen with the hidden field and with the javascript calendar?
    regards,
    ajos

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Post some code or a link to a test page.

      Comment

      • ajos
        Contributor
        • Aug 2007
        • 283

        #4
        Originally posted by acoder
        Post some code or a link to a test page.
        hey thanks for the reply,
        Well as i explained about the page flow, i have 3 jsp page next to next i dont know how to put forward the code. Talking about the javascript, the situation is when i enter some values in the a.jsp and click enter the first time the javascript works(for the date picker function). This takes the user to b.jsp page, where he enters some values, and if the values are still remaining to be entered, the user is again taken back to the a.jsp page where for the 2nd time the javascript datepicker fails to execute. I hope i have conveyed myself right. Since i dont have a link to a test page all i could do is to explain the situation a bit more clearly. :)

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Unless I can see the code, I can only guess what the problem might be.

          The server-side validation should work whether there's any client-side validation or not. If you've got client-side validation, it should not submit the page. If it is, you've probably got an error. Post the validation code in a.jsp.

          Comment

          • ajos
            Contributor
            • Aug 2007
            • 283

            #6
            Originally posted by acoder
            Unless I can see the code, I can only guess what the problem might be.

            The server-side validation should work whether there's any client-side validation or not. If you've got client-side validation, it should not submit the page. If it is, you've probably got an error. Post the validation code in a.jsp.
            Sorry for the late reply. My understanding on client side/server side scripting is that even if i have a server side script for validation, the client side runs first and ultimately the server side script doesnt work. Please correct me if im wrong here :)

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by ajos
              Sorry for the late reply. My understanding on client side/server side scripting is that even if i have a server side script for validation, the client side runs first and ultimately the server side script doesnt work. Please correct me if im wrong here :)
              I wouldn't say it doesn't work. The client-side code does indeed run first. If it passes, the form will submit and the server-side script will run. That way it is validated on both the client and server side. The advantage of client-side validation is that it avoids the need to make a trip to the server just to be greeted with an error message.

              Comment

              Working...