Topic: Validating radio buttons an others

Hi folks!
I' am having trouble to validate 35 groups of five radiobuttons with Xajax and also validate Combolists and fiald name.

Does anybody have a tip/hint/lesson/tutorial for me?

Thanks a lot.

Re: Validating radio buttons an others

Please give us some html/javascript...

3 (edited by edrobinson 2008-05-08 8:36:46 PM)

Re: Validating radio buttons an others

Hi,

Here's a working sample:

<?php
require_once ("xajax_0.5_beta4b/xajax_core/xajax.inc.php");
$xajax = new xajax();
$xajax->registerFunction("Test");  //Register the function
$xajax->processRequest();                  //Call the XAJAX engine

function test($dta) {
extract($dta);
$resp = new xajaxResponse();
$s = '';
if ($r1 == '')
    $s .= "R1 value not chosen\n";
if ($r2 == '')
    $s .= "R2 value not chosen\n";
if ($r3 == '')
    $s .= "R3 value not chosen\n";
if ($r4 == '')
    $s .= "R4 value not chosen\n";
if ($r5 == '')
    $s .= "R5 value not chosen\n";
if ($s1 == '')
    $s .= "Combo S1 was not chosen.\n";
if ($inp1 == '')
  $s .= "Field is a required element.";
if ($s != '')
    $resp->alert("PLease fix the following:\n" .$s);
else
    $resp->alert("All is Well.");    
return $resp;
}
//$xajax->setFlag('debug', true);
?>

[code=html]
<html>
<head>
  <?php $xajax->printJavaScript('xajax_0.5_beta4b'); ?>
</head>
<body>
<form id="form1" action="">
<p>Radio1
<input type="radio" id="r1", name="r1" value="1">1
<input type="radio" id="r1", name="r1" value="2">2
<input type="radio" id="r1", name="r1" value="3">3
<input type="radio" id="r1", name="r1" value="4">4
<input type="radio" id="r1", name="r1" value="5">5
</p>
<p>Radio2
<input type="radio" id="r2", name="r2" value="1">1
<input type="radio" id="r2", name="r2" value="2">2
<input type="radio" id="r2", name="r2" value="3">3
<input type="radio" id="r2", name="r2" value="4">4
<input type="radio" id="r2", name="r2" value="5">5
</p>
<p>Radio3
<input type="radio" id="r3", name="r3" value="1">1
<input type="radio" id="r3", name="r3" value="2">2
<input type="radio" id="r3", name="r3" value="3">3
<input type="radio" id="r3", name="r3" value="4">4
<input type="radio" id="r3", name="r3" value="5">5
</p>
<p>Radio4
<input type="radio" id="r4", name="r4" value="1">1
<input type="radio" id="r4", name="r4" value="2">2
<input type="radio" id="r4", name="r4" value="3">3
<input type="radio" id="r4", name="r4" value="4">4
<input type="radio" id="r4", name="r4" value="5">5
</p>
<p>Radio5
<input type="radio" id="r5", name="r5" value="1">1
<input type="radio" id="r5", name="r5" value="2">2
<input type="radio" id="r5", name="r5" value="3">3
<input type="radio" id="r5", name="r5" value="4">4
<input type="radio" id="r5", name="r5" value="5">5
</p>
<select id="s1" name="s1">
<option value="">Pick a Number</option>
<option value="1">1</option>
<option value="2">2</option>
</select>

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

4 (edited by marshallberg 2012-03-19 5:00:32 PM)

Re: Validating radio buttons an others

Hi all

What's the point of having Id at all if the name is the same value?