Inside the key...">

How to make data confidential and readonly?

I am entering comments.

<div class="comment-input" contenteditable></div>

      

Inside the keydown event, I want to define what type of new comment is? In my example, there are 2 types: New comment and Reply comment.

My idea: add attribute comment-level

to div. For example:

<div class="comment-input" data-comment-level="0" contenteditable></div>

      

or

$('.sub-comment [contenteditable]').data('comment-level', 1);

      

If comment-level

- 0

, this is a new comment. Otherwise, he replies to the comment.

Problem: Both can be easily edited on the client side. While clicking F12

to edit an attribute on a tab Elements

or tab Console

, try typing:

// you are hacked
$('.sub-comment [contenteditable]').data('comment-level', 'foo');

      

My question is, how can I securely install / retrieve data?

+3
javascript jquery


source to share


No one has answered this question yet

Check out similar questions:

7728
How do I redirect to another web page?
7649
How does JavaScript blocking work?
7494
How can I remove a specific element from an array in JavaScript?
7432
How to check if a string contains a substring in JavaScript?
7428
How can I check if an element is hidden in jQuery?
5722
How can I remove a property from a JavaScript object?
5129
How do I return a response from an asynchronous call?
4829
How do I include a JavaScript file in another JavaScript file?
4345
How to check if a checkbox is checked in jQuery?
3515
How do I make the first letter of a string uppercase in JavaScript?



All Articles
Loading...
X
Show
Funny
Dev
Pics