...

View Full Version : substring if statement



Baleric
02-13-2007, 09:56 PM
hey guys,
i got a form that onsubmit uses this jscript to validate



<script type="text/javascript">

function onSubmitForm(thisForm) {
if (!(/\.(zip|rar)$/.test(thisForm['attach1'].value))) {
alert('.ZIP and .RAR file type only please.');
return false;

}
}


</script>

if possible i need a substring in this script that that checks the first 7 letters of a textfield called 'nID' is 'STEAM_0' wich will then alert aswell.

thanks in advace

cheers

brandonH
02-14-2007, 01:18 AM
just checking for the exact value "STEAM_0" or are there other possible valus to check for?

brandonH
02-14-2007, 01:26 AM
<html>
<head></head>
<body>

<input type=text id=nID>
<input type=button onclick=getit()>


<script type=text/javascript>
function getit(){
var text=document.getElementById('nID').value;
var text2=text.substring(0,7);
if(text2.toUpperCase()=='STEAM_0'){alert('yes');}

}

</script>

</body>



</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum