• Post Reply Bookmark Topic Watch Topic
  • New Topic

String compare

 
Amod Mulay
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HOw to compare a String (JAVA)in jsp with a var in javascript. the var value will be from a field and the comparision should not be case sensitive.....can anyone help me out here
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amod Mulay:
HOw to compare a String (JAVA)in jsp with a var in javascript. the var value will be from a field and the comparision should not be case sensitive.....can anyone help me out here


You can compare javascript variable with java string but reverse is not possible in JSP.

In javscript convery the variable to upper case and compare. You can use value.toUpperCase() to convert a variable to upper case in Javascript.
 
IM Mahesh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the value of java string in one javascript var, and then compare them.
e.g.
var value = yourJavaString;
if(value.toLowerCase() == jsVarToCompare.toLowerCase()) {
//your code
}
 
Jass Singh
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by IM Mahesh:
Get the value of java string in one javascript var, and then compare them.
e.g.
var value = yourJavaString;
if(value.toLowerCase() == jsVarToCompare.toLowerCase()) {
//your code
}



For more clarity on how to get recieve value in javascript :




Regards,
Jass
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!