Advertisement

05.05.2007 at 06:38AM PDT, ID: 22554547
[x]
Attachment Details

radio button select/enable text area and validate input is a #

Asked by elysiandc in Scripting Languages, JavaScript, Dynamic HTML (DHTML)

Tags: radio, button, enable, text

Hi there,

I have a pair of radio buttons, one with a text field. I'm trying to figure out how to
  1. enable/set focus to the text field when the button is selected    and
  2. verify that there is info in the text field   and
  3. verify that the info is a number. It needs to be a whole # or limited to 2 decimal places (ie a monetary value)

Here is a snippet with the buttons...

<?php
        if ($deposit == "0"){
         echo "<input type='hidden' name='payment' value='".$page_price."'>";}
        else {
         echo "<tr>
       <td width='160' height='25' valign='bottom' class='forumheader2'>Payment options :</td>
       <td width='410' height'25' valign='bottom' class='forumheader3'><input type='radio' name='payment' value='".$page_price."' checked='true'>Pay in full</td></tr>
       <tr><td width='160' height='25' valign='bottom' class='forumheader2'></td>
       <td width='410' height='25' valign='bottom' class='forumheader3'><input type='radio' name='payment' onClick='other.focus()'>Deposit :  $<input type='text' name='part_amount' class='tbox' value='' id='other'></td>
      </tr>";
      }?>

And here is some verification code I have already which checks some other text fields later in the form....

function formCheck(formobj){
      // Enter name of mandatory fields
      var fieldRequired = Array("firstName", "lastName", "address", "location", "state", "postcode", "phone", "mobile", "email");
      // Enter field description to appear in the dialog box
      var fieldDescription = Array("First Name", "Last Name", "Address", "Suburb", "State", "Postcode", "Phone #", "Mobile #", "E-Mail");
      // dialog message
      var alertMsg = "Please complete the following fields:\n";
      
      var l_Msg = alertMsg.length;
      
      for (var i = 0; i < fieldRequired.length; i++){
            var obj = formobj.elements[fieldRequired[i]];
            if (obj){
                  switch(obj.type){
                  case "select-one":
                        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "select-multiple":
                        if (obj.selectedIndex == -1){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "text":
                  case "textarea":
                        if (obj.value == "" || obj.value == null){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  default:
                  }
                  if (obj.type == undefined){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                              if (obj[j].checked){
                                    blnchecked = true;
                              }
                        }
                        if (!blnchecked){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                  }
            }
      }

      if (alertMsg.length == l_Msg){
            return true;
      }else{
            alert(alertMsg);
            return false;
      }
}

Any assistance with this would be greatly appreciated, as my JavaScript skills are practically non-existent. I have pieced all of the above together by searching the net and am now a bit stuck.

Many thanksStart Free Trial
[+][-]05.05.2007 at 07:34AM PDT, ID: 19036478

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.

 
[+][-]05.05.2007 at 03:27PM PDT, ID: 19037645

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

 
[+][-]05.21.2007 at 07:03AM PDT, ID: 19126938

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

 
[+][-]05.21.2007 at 08:06PM PDT, ID: 19131585

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.

 
[+][-]05.21.2007 at 09:45PM PDT, ID: 19131821

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

 
[+][-]05.21.2007 at 10:31PM PDT, ID: 19131912

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.

 
[+][-]05.21.2007 at 10:57PM PDT, ID: 19131964

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

 
[+][-]05.22.2007 at 12:28AM PDT, ID: 19132184

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.

 
[+][-]05.22.2007 at 02:12AM PDT, ID: 19132486

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.

 
[+][-]05.22.2007 at 02:28AM PDT, ID: 19132553

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

 
[+][-]05.22.2007 at 03:20AM PDT, ID: 19132705

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.

 
[+][-]05.22.2007 at 03:57AM PDT, ID: 19132826

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

 
[+][-]05.22.2007 at 04:22AM PDT, ID: 19132925

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.

 
[+][-]05.22.2007 at 04:59AM PDT, ID: 19133084

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

 
[+][-]05.22.2007 at 05:06AM PDT, ID: 19133107

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.

 
[+][-]05.22.2007 at 05:12AM PDT, ID: 19133156

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.

 
[+][-]05.22.2007 at 05:28AM PDT, ID: 19133249

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

 
[+][-]05.22.2007 at 08:09AM PDT, ID: 19134569

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

Zones: Scripting Languages, JavaScript, Dynamic HTML (DHTML)
Tags: radio, button, enable, text
Sign Up Now!
Solution Provided By: Jaax
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.22.2007 at 08:35AM PDT, ID: 19134838

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

 
[+][-]05.22.2007 at 07:56PM PDT, ID: 19139114

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.

 
[+][-]05.23.2007 at 02:59AM PDT, ID: 19140317

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

 
[+][-]05.23.2007 at 03:29AM PDT, ID: 19140440

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.

 
 
Loading Advertisement...
20080716-EE-VQP-32