View Full Version : substring if statement

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;



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


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

02-14-2007, 01:26 AM

<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);





EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum