hi, My particular form start with 1 main pulldown, depending on the choice either formfieldsA.php or forrmfieldsB.php will be called by an ajax request. But now i don't know how to set up the JS validation, like i have something in the line of: <form name="Form" action="?action=step3" method="POST" onsubmit="return Validator(this);"> <select name="segment" id="segment" onchange="javascript:segmentForm2();"> <option value="">Segment</option> <option value="formfieldsA.php">A</option> <option value="formfieldsB.php">B</option> </select> <div id="formfields" style="display:none;"> </form> Code (markup): Based on segment the fields from formfieldsA.php or forrmfieldsB.php will be called by an ajax request. now for the validation part in index.php function Validator(theForm){ if ( document.Form.segment.value==0) { alert('segment'); document.Form.segment.focus(); return false;} if ( document.Form.cName.value.length<1) { alert('name'); document.Form.cName.focus(); return false;} ..... } Code (markup): works for all the fields in formfieldsA.php. But how do i check the fields in formfieldsB.php Any ideas??
You have to check first what formfield is selected Now you only check if no formfield is selected : if ( document.Form.segment.value==0) You need to add : if ( document.Form.segment.value=='formfieldsA.php'), and formfieldsB.php and validate the fields according to the selected form