...

View Full Version : I remember something like: 'john | james | mary'\i.indexOf(compareVar) etc....



BrightNail
06-25-2004, 10:48 PM
I remember someone posting something like this...
where we need to compare numerous strings against ONE var...and instead of doing a bunch of if else statements, there was something like:

\' james | john | mary \'/i.indexOf(comparedVar) != -1

or something like this...where we want to know if James, or John or mary --- case insensitive is within the var "comparedVar".....????

Willy Duitt
06-25-2004, 10:56 PM
<script type="text/javascript">
<!--//
function validate(input){
var regEx = /james|john|mary/gi;
if(input.value.match(regEx)){
alert('match');
}
}
//-->
</script>
</HEAD>

<body>
<form>
<input onblur="validate(this)">
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum