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'>Payme
nt options :</td>
<td width='410' height'25' valign='bottom' class='forumheader3'><inpu
t 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'><inpu
t type='radio' name='payment' onClick='other.focus()'>De
posit : $<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[fieldRequ
ired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIn
dex].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 thanks
Start Free Trial