Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts

    substring if statement

    hey guys,
    i got a form that onsubmit uses this jscript to validate

    Code:
    <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

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    just checking for the exact value "STEAM_0" or are there other possible valus to check for?
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    <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>
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •