JQuery Validation not working on Ajax Control…!

D3v

New Member
Hi there I have Problem with my Code I just want to validate States which is generated from Ajax response.textHere is the JQuery for State Field \[code\]$(document).ready(function(){var form = $("#addStudentfrm"); var state = $("#state");var stateInfo = $("#stateInfo"); state.blur(validateStates); state.keyup(validateStates); function validateStates(){ if(state.val()== ''){ state.addClass("error"); stateInfo.text("Please Select/Enter State"); stateInfo.addClass("error5"); return false; }else{ state.removeClass("error"); stateInfo.text(""); stateInfo.removeClass("error5"); return true; }} });\[/code\]Here PHP Function for Get All States in Respected Country\[code\]public function getAllCountryStates($post){$que = "Select * from ".WMX_COUNTRY." where code = '".$post[value1]."'";$cRes = $this->executeQry($que);$cResult = $this->getResultRow($cRes);$cId = $cResult['id'];$stateObj = new Admin;$rdat = $post['opr'];$rdtar = explode('.', $rdat);$res = @mysql_fetch_row(mysql_query("Select * from ".$rdtar['1']." where id = ".$rdtar['0']));$usts = $res['state'];$result = $stateObj->selectQry(WMX_STATE,"country_id=$cId",'','');$number = $stateObj->getTotalRow($result);if($number > 0){ $getSelect ="<select name='state' id='state' class='textboxcss'>"; while($stateVal = $stateObj->getResultRow($result)){ $getSelect.="<option value='".$stateVal[state]."'>$stateVal[state]</option>";} $getSelect.="</select>";}else{ if($usts!=''){ $getSelect = "<input type='text' name='state' id='state'class='textboxcss' value='http://stackoverflow.com/questions/3879306/$admnState'/>"; } else { $getSelect = "<input type='text' name='state' id='state' class='textboxcss'/>"; }} echo $getSelect; }\[/code\]In the Initial State Text box getting validate but when the control comes with the Ajax Response Jquery wont validate it for Blank Entriesmy Ajax Function \[code\]function DataByPost(url,objId,postData,div_id){ var selId = objId.split('|'); var passData = http://stackoverflow.com/questions/3879306/postData; var AJAX = null; if (window.XMLHttpRequest) { AJAX=new XMLHttpRequest(); } else { AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (AJAX==null) { alert("Your browser doesn't supportAJAX.");
return false } else { AJAX.open("POST",url,true); AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); AJAX.onreadystatechange = function() { if (AJAX.readyState==4 || AJAX.readyState=="complete"){
alert(AJAX.responseText); var msg=AJAX.responseText; var idary = new Array(); document.getElementById(selId).value = http://stackoverflow.com/questions/3879306/msg; document.getElementById(selId).innerHTML = msg; } } AJAX.send(passData); }}//First Function function showContent(url,arg,opr,sel_id,div_id){
var postData='';
var formVal=arg.split('|'); if(document.getElementById(div_id))
document.getElementById(div_id).style.display=''; if(document.getElementById(sel_id))
document.getElementById(sel_id).style.display=''; for(i=1;i<=formVal.length;i++) var postData =http://stackoverflow.com/questions/3879306/postData +'value'+i+'='+escape(formVal[i-1])+'&'; postData=http://stackoverflow.com/questions/3879306/postData +'opr='+opr; DataByPost(url,sel_id,postData,div_id);
} \[/code\]
 
Back
Top