Javascript examples for String:substring
Use string indexOf to check if a substring exists
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w . j a v a 2s . c om var password = 'try'; var emailSubstring = 'try@email.com'; if ( password.indexOf( emailSubstring ) != -1 ) { console.log( '1' ); } if ( emailSubstring.indexOf( password ) != -1 ) { console.log( '2' ); } } </script> </head> <body> </body> </html>