jeudi 14 avril 2016

django validate form random generated value

This problem is not exactly the same as mine, but the concept is similar and familiar.
Consider a phone number registration form:
The user fill some details, and then, if he choose to get a new phone number, the client send an ajax request and the server returns a newly generated random number. unique number.

The problem: when the client submits the form, I need to validate that the same random number which was assigned to him in the ajax request, is equals to the number that the client send in the from submission. How can I solve this? I thought of using the session, to store the number the was generated in the ajax request. But that would be a problem if the user refreshes the page, or what if he open the same form in two different windows? Can I limit the client from doing so? (blocking the form if it's already open)




Aucun commentaire:

Enregistrer un commentaire