I need to set values for all inputs with ids like re_widget[num][widget_id] . Now I have something like this:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var result = /^\d{1,2}$/;
$('input[id="re_widget[+result+][widget_id]"]').val("my_value");
});
});
</script>
</head>
<body>
<p>Name: <input id="re_widget[1][widget_id]" type="text" name="user1"></p>
<p>Name: <input id="re_widget[2][widget_id]" type="text" name="user2"></p>
<p>Name: <input id="re_widget[3][widget_id]" type="text" name="user3"></p>
<button>Set the value of the input field</button>
</body>
</html>