Reputation: 1014
I want to find whether the text in the input field contains any space character.For that I use the statement
$("#myTextBox").val().trim().contains(" ");
this should return true
if the text in the textbox contains any space. But the problem is this is not working in Chrome and IE. It returns an error Uncaught TypeError: undefined is not a function
in chrome's console. While in Firefox it is working fine.
What would be the probable reason. Is it curable?
Please find the jsfiddle http://jsfiddle.net/1L1pf7c7/3/
Upvotes: 1
Views: 511
Reputation: 82241
You can use indexOf(' ')
with value to check space/whitespace character existence
if($("#myTextBox").val().indexOf(' ')>=0){
//space exists
}
Upvotes: 1