php - jquery remote validation not working when two fields having same id -
i have html form ..
<span id="langbrowser"></span> <table> <tr> <td id="sign_up" class="heading"></td> <td style="text-align:right"> <span class="close_font"><b>close</b></span> <?php echo chtml::image(yii::app()->baseurl.'/images/close_icon.png',"",array('id'=>'close_reg_icon','style'=>'title:advertisement;margin-top:5px;')); ? </td> </tr> <tr><td colspan="2" id="label1" class="sub_heading"></td></tr> <tr><td colspan="2"><hr/></td></tr> <tr> <td style="display:none" class="success" colspan="2" align="center">you registered in mylokal network, please check email activating account.</td> </tr> <tr><td> </td></tr> </table> <div id="success_hide"> <table> <tr> <td id="first_name_label_register" style="text-align:right;width:30%" class="label"></td> <td><?php echo $form->textfield($model,'usr_firstname',array('name'=>"first_name",'id'=>"first_name",'class' =>'inputtext')); ?></td> </tr> <tr> <td id="last_name_label_register" style="text-align:right" class="label"></td> <td><?php echo $form->textfield($model,'usr_lastname',array('name'=>'last_name','id'=>"last_name",'class'=>'inputtext')); ?></td> </tr> <tr> <td id="email_label_register" style="text-align:right" class="label"></td> <td><?php echo $form->textfield($model1,'uem_email',array('name'=>'register_email','id'=>"register_email",'class'=>'inputtext')); ?></td> </tr> <tr> <td id="reenter_email_label_register" style="text-align:right" class="label"></td> <td><?php echo $form->textfield($model1,'repeat_email',array('name'=>'reenter_email','id'=>"reenter_email",'class'=>'inputtext')); ?></td> </tr> <tr> <td id="new_password_label_register" style="text-align:right" class="label"></td> <td><?php echo $form->passwordfield($model,'usr_password',array('name'=>'passwd','id'=>"passwd",'class'=>'inputtext')); ?></td> </tr> <tr> <td id="date_of_birth_label_register" style="text-align:right" class="label"></td> <td><?php $this->widget('zii.widgets.jui.cjuidatepicker', array( 'model'=>$model, 'attribute'=>'usr_date_of_birth', 'options'=>array( 'dateformat'=>'yy-mm-dd', 'changemonth'=>true, 'changeyear'=>true, 'showanim'=>'fold', 'yearrange'=> '1910:2020', 'maxdate'=>'new date();' ), 'htmloptions'=>array( 'id'=>'dob', 'name'=>'dob', 'class'=>'inputtext', 'readonly'=>true, 'style'=>'width:207px;', 'language'=>'de' ), ));?></td> </tr> <tr><td class="label"></td><td id="birth_label"></td> </tr> <tr><td class="label"></td> </tr> <tr><td class="label"></td><td id="terms_label"> </td> </tr> <tr><td> </td></tr> <tr><td> <input type="hidden" name="pid" value="<?php echo $pid;?>" /></td> <td><?php echo chtml::button('cancel',array('name' => 'cancel_reg_button','id'=>'cancel_reg_button','style'=>'background: #ffffff;color:black')); ?> <?php echo chtml::submitbutton('sign up',array('id'=>'button','name' => 'button2','style'=>'background: #6495ed;color:white')); ?></td></tr> </table> </div>
and jquery form validation , rules this..
jquery.validator.addmethod("agecheck", function(value, element) { var now=new date(); var selected_date_array = jquery("#dob").val().split("-"); var selected_date = new date(selected_date_array[0],selected_date_array[1]-1,selected_date_array[2]); return selected_date < now; }, "selected date must less current date"); jquery.validator.addmethod("checkemails", function(value, element) { return value.tolowercase()==jquery("#register_email").val().tolowercase();
}, "please enter same value in email field");
jquery(document).ready(function(){
jquery('#reenter_email').bind("cut copy paste",function(e) { e.preventdefault(); }); jquery('#mlusers-register-form').validate({ errorclass: "error", errorelement: "div", rules:{ reenter_email:{required: true, email: true,checkemails:true}, passwd:{required: true,minlength:6}, dob:{required: true,dateiso: true,agecheck:true}, first_name:{required:true,firstname: true}, last_name:{required:true,lastname: true}, register_email:{required: true, email:true,remote:{url:'./index.php?r=user/unique_email_check',async: false}} }, messages:{ first_name:{required:" first name field cannot blank"}, last_name:{required:" last name field cannot blank"}, register_email:{required:" email field cannot blank",remote:"email id registered"}, reenter_email:{required:" re-enter email field cannot blank"}, passwd:{required:" new password field cannot blank",minlength: "min length 6."}, dob:{required:" date of birth field cannot blank",dateiso: "invalid date. must formatted yyyy-mm-dd"} }, submithandler: function(form) { jquery(form).ajaxsubmit({ url:"./index.php?r=mlusers/sign_up", type:"post", success: function(){ jquery("#success_hide").hide(); jquery(".success").show(); } }); } });
});
coming remote validation existing email working fine , okay ..
but problem when in registration form replace id of 'your email' field of 're-enter email' field using firebug.
the remote validation showing error email registered form submitting .. what's wrong this..
please me in why happening ..
and php function
public function actionunique_email_check(){ //echo "<pre>";print_r($_post);exit; //sleep(10); $email=$_get['register_email']; $emails_array= useremails::model()->findallbyattributes(array('uem_email'=>$email)); if(count($emails_array) > 0){ echo json_encode(false); } else{ echo json_encode(true); } }
please me in this, urgent... , major bug..
thank you...
try use class attribute instead of id
Comments
Post a Comment