search

Home  >  Q&A  >  body text

javascript - It is very tedious to verify form data on both the client and the server. How to optimize it?

I don’t know if there is a more convenient method.

PHP中文网PHP中文网2736 days ago705

reply all(4)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-29 10:09:58

    This is a problem of user experience
    Front-end verification is to allow illegal data to report errors in time without submitting it to the server and without network requests. This experience is good because it is impossible to load and then request the server every time it is submitted

    Server-side verification is for final data security to prevent illegal data entry

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-29 10:09:58

    This is not a problem of optimization. It is better not to be lazy when passing parameters. There should be no less verification

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-29 10:09:58

    It is definitely safer to verify both the front and back ends.

    If you want to be lazy, just don’t verify the front end or do some simple verification. Let the back end verify and return an error message every time. But this is not an optimization.

    reply
    0
  • 欧阳克

    欧阳克2017-06-29 10:09:58

    Let me talk about the conclusion first, there is no way to optimize it.

    Front-end verification is mainly for user experience, without requesting the server or requesting the server without refreshing the page.
    Server-side verification is to verify the correctness and legality of the data and ensure that the data written to the database meets business requirements.

    reply
    0
  • Cancelreply