开发者

How can i validate formfields which are loaded into a $.post div?

I am using validation.php by benjaminkeen to validate a form. The catch is i have stage3.php which loads two different forms base on selection. And i have the opening tag and closing tag in stage3.php. Two different forms are loaded by jquery and these files ar e just form fields in a .php file. I have also all the validation rules in stage3.php. But as soon as the form submits the select form disappears.

<?php
$errors = array(); // set the errors array to empty, by default
$fields = array(); // stores the field values
$success_message = "";

if (isset($_POST['submit']))
{ 
//rules
...........
$("#segment2").change(function() {
    var file = $("#segment2").val();
    var pars = {
countries : '<?php echo $json->encode($country);?>',
        price : '<?php echo $_POST['price']; ?>',
        descr : '<?php echo $_POST['descr']; ?>'
    };
    if((file != '') && (submitcount == 0))
    {
    $.post(file, pars, function(data) {
            $('#selectedform').html(data).show(300);
    });
    // submitcount++;
    } else {
    var file = "blank.htm";
    $('#selectedform').load(file).hide();
    }
});
<form name="formTest" method="POST" action="">
    <select name="segment2" id="segment2">
        <option 开发者_如何转开发value="">Segment jQuery</option>
        <option value="luxury.php">luxury</option>
        <option value="nonluxury.php">nonluxury</option>
    </select>
    <div id="selectedform" style="display:none;"></div>
    <div id="systemWorking" style="display:none"><img src="imgs/ajax-loader.gif" alt="Laden" /></div>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜