Reputation: 85
I have function to get radio button value.
var val = $('input[name="test_'+ id +
'"]:checked').val();
but it cause DOM XSS. How do I refactor to prevent XSS?
thanks.
Upvotes: 2
Views: 577
Reputation: 371193
This does not have an XSS vulnerability except in extremely ancient versions of jQuery, so it's probably not something to worry about.
Avoiding jQuery and using querySelector
will work though.
const val = document.querySelector('input[name="test_'+ id + '"]:checked').value;
Upvotes: 1