How to validate textbox's value

ktosek

New Member
Here is the code. There are two different files1 metadata.php \[code\]<script> $(document).ready(function(){ $("#addAuthor").click(function(e){ e.preventDefault(); $.ajax({url:"n.php",type: "POST",data: ({id: '1'}),success:function(result){ $("#div1").append(result); }}); }); $("#removeAuthor").click(function(e){ e.preventDefault(); var lastNode = $("#div1").children().last(); lastNode.prev().remove(); lastNode.remove(); }); }); </script> <div id="div1" > </div> <button id="addAuthor" >Add Author</button> <button id="removeAuthor">Remove Author</button><input type="submit" name="save" value="http://stackoverflow.com/questions/15861252/Save & Continue">\[/code\]2 n.php\[code\]Name:<input type="text" name="txtname[]">age:<input type="text" name="txtage[]">\[/code\]Now what happens on the click of 'addAuthor' butoon ajax loads all the content of n.php as many times as button clicks.And txtname[] and txtage[] will store all the textbox's value.But these arrays will give values on the form post.So how can i validate textbox's value before form post?Because If I validate values on form post,and if validation fails then metadata.php will not remain with n.php 's loaded content.So how can i do this??
 
Back
Top