0

Auto Field generated by YII2

<input type="text" class="form-control" name="TABELACOSearch[ID_VANTIVE]" value="">

My JS:

$(document).ready(function(){
var teste = $("input[name=TABELACOSearch[ID_VANTIVE]]").val();
console.log(teste)

}); 

I believe the problem is the field name with [], but i can't change the name of the field , and i just need to copy the value from 5 fields like that OBS : i can't add class and ID . What can i do ??

And the error :

jquery.js:1468 Uncaught Error: Syntax error, unrecognized expression: input[name=TABELACOSearch[ID_VANTIVE]]
at Function.Sizzle.error (jquery.js:1468)
at Sizzle.tokenize (jquery.js:2125)
at Sizzle.select (jquery.js:2546)
at Function.Sizzle [as find] (jquery.js:869)
at jQuery.fn.init.find (jquery.js:2792)
at jQuery.fn.init (jquery.js:2909)
at jQuery (jquery.js:75)
at HTMLDocument.<anonymous> (index.php?TABELACOSearch[ID_VANTIVE]=&TABELACOSearch[ID_VANTIVE_ANTIGO]=&TABELACOSearch[STATUS]=&TABELACOSearch[NUM_LP]=&TABELACOSearch[CLIENTE]=&r=qualidade:135)
at n (jquery.min.js:2)
at Object.fireWith (jquery.min.js:2)
Samuil Petrov
  • 542
  • 1
  • 13
  • 24

1 Answers1

1

You can escape it with two backslash as mentioned here: http://api.jquery.com/category/selectors/

racz_gabor
  • 249
  • 1
  • 9