Forum Moderators: open

Message Too Old, No Replies

validation

         

ttkt

6:13 am on Feb 10, 2005 (gmt 0)

10+ Year Member



hi all, I would like to do a check on the Type of Material multiple list field. if Newspaper is selected, page read from field (textbox) and page read to field (textbox) will not be validated to check if it is empty. if Comics or magazine etc is selected, the page read from field and page read to field will be validated.

may i know how do i go about it? below is the code:

// must select 1 item - multi list combo box
function FcheckDropMultiple(n,v,mi){

var sel = 0;
var i;
for (i = 0; i < v.length; i++)
{
if (v.options[i].selected)
sel++;
}

if(mi>0){
if (sel < mi) { alert("Please select an item for "+n+"!");return false; }
}
return true;
}

// validate update.php - reading log
function checkform_update(f)
{
input_box = confirm("Would you like to edit the record?");
if (input_box==true)
{
// for day - update page
if(!FcheckDropMultiple('Day',f.d_date1,1)){ return false;}//name,field,min

// for month - update page
if(!FcheckDropMultiple('Month',f.d_date2,1)){ return false;}//name,field,min

// for year - update page
if(!FcheckDropMultiple('Year',f.d_date3,1)){ return false;}//name,field,min

// for type of material - update page
if(!FcheckDropMultiple('Type of Material',f.d_material,1)){ return false;}//name,field,min

// for type of subject - update page
if(!FcheckDropMultiple('Subject',f.d_subject,1)){ return false;}//name,field,min

// for title - update page
if(!FcheckFilled('Title',f.d_title.value)){ f.d_title.focus();return false;}

// for page read from - update page
if(!FcheckNumber('Page Read From',f.d_pagefrom.value)){ f.d_pagefrom.focus();return false;}

// for page read to - update page
if(!FcheckNumber('Page Read To',f.d_pageto.value)){ f.d_pageto.focus();return false;}

// for no. of articles - update page
if(!FcheckNumber('No. of Articles',f.d_noa.value)){ f.d_noa.focus();return false;}

// for place of reading - update page
if(!FcheckDropMultiple('Place of Reading',f.d_por,1)){ return false;}//name,field,min

// for time spent - update page
if(!FcheckNumber('Time Spent',f.d_tp.value)){ f.d_tp.focus();return false;}

return true;
}
else
{ return false;}
}

<td><select name="d_material" size="3" id="d_material">
<option value=Books <?php if (!(strcmp("Books", $d_material))) {echo "SELECTED";}?>>Books</option>
<option value=Comics <?php if (!(strcmp("Comics", $d_material))) {echo "SELECTED";}?>>Comics</option>
<option value=Magazine <?php if (!(strcmp("Magazine", $d_material))) {echo "SELECTED";}?>>Magazine</option>
<option value=Newspaper <?php if (!(strcmp("Newspaper", $d_material))) {echo "SELECTED";}?>>Newspaper</option>
</select>
</td>


<td><div align="center">
<input name=d_pagefrom type=text id="d_pagefrom" value="<?= $d_pagefrom?>" size=2>
</div></td>
<td><div align="center">
<input name=d_pageto type=text id="d_pageto" value="<?= $d_pageto?>" size=2>
</div></td>

orion_rus

10:49 am on Feb 14, 2005 (gmt 0)

10+ Year Member



May be u should use onclick event in a checkbox and when call a function which checks content and send it to required textarea. Is what u mean?
If it's so it's very simple. I can show u example if u want.
Good luck to you

ttkt

3:04 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



hi orion_rus, i have solved the problem...thanks!