Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to implement Java String's indexOf function in my javascript

843838Apr 25 2007
Hi,
i want to implement Java String's indexOf function in my javascript.


javacode:
String s1= "abc";
Sring s2 = "xyzabcxyz";
if((s2.indexOf(s1))==-1)
{ return;}


i want to implement the same logic in my javascript
where string s1 given by --document.form1.s1.value
string s2 given by --document.form2.s2.value

how can i use indexof method here?can anyone please tell me
i tried with this but its not working

if((document.form1.s1.value.indexOf(document.form2.s2.value))==-1)
{ alert ("s2 not found in s1");}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 23 2007
Added on Apr 25 2007
0 comments
199 views