javascript - How do I validate dynamically created controls in jquery at server side - Php


I am creating an applicaiton where hundreds of controls are created dynamically in Jquery as below.

var $link='<a id="bucket'+data[0].ID+'" class="Initial" href="#"></i></a>';  

While adding controls I am assigning unique ID to each control.

And this is how I am identifying each control while accessing it.


 var $"bucket","");

But here's the issue.

These IDs can be changed at browser with "Inspect Element" option.

ServerSide Situation

IDs which I have assigned to controls, are the primary keys of row in table called employee.

So changing ID at browser can temper data in a different row than intended.

How do I validate these controls at serverside, if ID is changed or not or How do I restore original ID of an element at server side??

I hope my question is clear enough.

Any help is apppreciated.

For everyone who thinks this is not possible.. I would ask - How does facebook or even StckOverflow do it??




You need to define it differently for it to work with dynamic elements:

$(document).on("click", ".Initial", function(){
  var $"bucket","");

It is impossible to detect if anybody has changed the ID via the browser.




You can't (software rule n°1: never trust user input).

What you can validate serverside is:

  • Make sure the id exists
  • Make sure the user has the rights to do the action on the data related to the id.

And this is it ! If a user is doing an action he is allowed to, on valid data, why should he be stopped to do so ?

People are also looking for solutions to the problem: php - Laravel 5.2 eloquent save() method store number 0 in Oracle become 4294967296


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.