[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

extract numbers from a string and operate with them

Asked by paStiSSet in JavaScript

Tags: from, numbers, string

hello all and thanks for reading this post.

i have a form with a text input, where the user can write the kind of teams where sorted on the game they played. but, i want to limit the "text" that the user is wrinting, cos the game is limited to 8 players, and i don't want them typeing something like 5vs6 or 7vs4 (game's max players numbers, how i said, is 8).

so, i though to take the string of the text input and scan the following things:
- it must be less than 4 characters in the string
- if there is no teams, the user must specify the number of players, just the number
- and finally, limit the number of players to 8

theres the code that i have:

function comprueba() {
      if(document.pSubir.pJugadoresOtro.value.length > 4) {
            alert("Error en el numero o equipos de jugadores\n\naoc-hispano.com");
            document.pSubir.siguiente1.value = "no";
      }
      if ((document.pSubir.pJugadoresOtro.value.length >= 1) && (document.pSubir.pJugadoresOtro.value.indexOf("vs") == -1)) {
            alert("Los equipos deben estar especificados siguiendo este formant:\n\n\t\t\tXvsY\n\nLo que significa que si es una partida de 3 contra 2, se debería indicar:\n\n\t\t\t3vs2\n\naoc-hispano.com");
            document.pSubir.siguiente1.value = "no";
      }
      
      var uno=document.pSubir.pJugadoresOtro.substring(0,1);
      var dos=document.pSubir.pJugadoresOtro.substring(0,4);
      
      if((document.pSubir.pJugadoresOtro.value.indexOf("vs") == 1) && (uno+dos > 8)) {
            alert("Contiene la cadena vs, y hay error en la cantidad de jugadores!");
            document.pSubir.siguiente1.value = "no";
      }
}

well, the two first "if" works correctly, but the third part of the function, its where i have problems to get it working.

surely that you will see some crazyness in this code, cos i just began to work in javascript last saturday..

the idea is to take the values of X and Y, from XvsY (4vs3, 2vs3, 1vs5...) and save them on a variable, called "uno" for X, and "dos" for Y. and test if uno+dos (X+Y) its bigger than 8.

if its bigger a window.alert will appear warning to the user that theres an error and the siguiente1.value will be assigned to "no".

i know the third part of the function its some kinda badly done, so do not think that u must be based on it

thanks all
[+][-]04/14/04 12:54 AM, ID: 10821192Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/14/04 01:23 AM, ID: 10821378Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]04/14/04 01:29 AM, ID: 10821408Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/14/04 01:45 AM, ID: 10821493Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]04/14/04 01:58 AM, ID: 10821573Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/14/04 02:00 AM, ID: 10821586Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/14/04 02:15 AM, ID: 10821659Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]04/14/04 02:53 AM, ID: 10821830Accepted Solution

View this solution now by starting your 30-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
Tags: from, numbers, string
Sign Up Now!
Solution Provided By: Zvonko
Participating Experts: 2
Solution Grade: A
 
[+][-]04/14/04 02:55 AM, ID: 10821839Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]04/14/04 07:56 AM, ID: 10823970Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89