Advertisement

06.26.2008 at 10:51AM PDT, ID: 23519156
[x]
Attachment Details

Need to alter a javascript function that looks at a specific character in a string, look for acceptable range of values.

Asked by electricd7 in JavaScript

Hello,

I have a javascript function that looks at a string value passed to it.  It is currently setup to look at the first 2 characters in the string, and if they are equal to a certain string, then do something, if not, do something else.  Anyway, I need to change that function to look at the first character and the second character independantly.  Kinda confusing, so here is the current function:

function bar_unit(f){
  if (Left(f.unit_num.value, 2)=="=W"){
        var unit_num = Right(f.unit_num.value, 15);
      var unit_num = Left(unit_num, 13);
       f.unit_num.value = unit_num;
  }
  else{
        return;
  }
}

Now what I want to do is check to be sure the first character is "=", then check the 2nd character and see if it is either A-Z or 1-9.  If the first charcter is "=" and the second is "A-Z" OR "1-9", then do the var unit_num part.  If either of those conditions are false (being the first "=" or the second is not A-Z or 1-9",  then return;  Thanks!
Start Free Trial
 
Loading Advertisement...
 
[+][-]06.26.2008 at 11:21AM PDT, ID: 21877533

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2008 at 11:25AM PDT, ID: 21877582

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Sign Up Now!
Solution Provided By: jrram
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628