jQuery form validation not working in CakePHP 2.8.5 -


actually html form contains textboxes name like, example name="data[user][username]" in cakephp 2.8.5.

how can write jquery form validation code form fields. why because when use validation have use textbox field name, cannot use entire textbox name data[user][username].

my code below:

<!doctype html> <html lang="en"> <head>     <?php echo $this->html->css('jquery-ui.min.css'); ?>     <?php echo $this->html->script('jquery.js'); ?>     <?php echo $this->html->script('jquery-ui.min.js'); ?>     <?php echo $this->html->script('jquery.validate.min'); ?>  <script>     $(function() {         // setup form validation on #register-form element         $("#useraddform").validate({              // specify validation rules             rules: {                 username: "required",                 password: {                     required: true,                     minlength: 5                 },                             full_name: "required",                 email: {                     required: true,                     email: true                 },                 phone: "required",                 role: "required"                         },                     // specify validation error messages             messages: {                 username: "please enter username",                 full_name: "please enter full name",                 password: {                     required: "please provide password",                     minlength: "your password must @ least 5 characters long"                 },                 email: "please enter valid email address"                  },          });     }); </head> <body>     <div class="col-lg-6">         <form role="form" name="add_userform" role="form" accept-charset="utf-8" enctype="multipart/form-data" method="post" id="useraddform" action="/invl_exams/users/add">             <div class="form-group">                 <label>username</label>                  <input type="text" class="form-control"  required="required" id="userusername" maxlength="255" name="data[user][username]" >                 <!--<p class="help-block">example block-level text here.</p> -->                  <label id="userusername-error" class="error" for="userusername"></label>                 </div>             <div class="form-group">                 <label>password:</label>                                                     <input type="password" class="form-control" required="required" id="userpassword" name="data[user][password]">                 <label id="userpassword-error" class="error" for="userpassword"></label>             </div>             <div class="form-group">                 <label>full name</label>                 <input type="text" class="form-control" required="required" id="userfullname" maxlength="255" name="data[user][full_name]">                 <label id="userfullname-error" class="error" for="userfullname"></label>             </div>             <div class="form-group">                 <label>email</label>                 <input type="email" class="form-control" required="required" id="useremail" maxlength="255" name="data[user][email]">                 <label id="useremail-error" class="error" for="useremail"></label>             </div>             <div class="form-group">                 <label>secondary email</label>                                              <input type="email" class="form-control" required="required" id="usersecemail" maxlength="255" name="data[user][secondary_email]">                 <label id="usersecemail-error" class="error" for="usersecemail"></label>             </div>             <div class="form-group">                 <label>phone</label>                                              <input type="text" class="form-control" required="required" id="userphone" maxlength="255" name="data[user][phone]">                 <label id="userphone-error" class="error" for="userphone"></label>             </div>             <div class="form-group">                 <label>secondary phone</label>                   <input type="text" class="form-control" required="required" id="usersecphone" maxlength="255" name="data[user][secondary_phone]">                 <label id="usersecphone-error" class="error" for="usersecphone"></label>             </div>             <div class="form-group">                 <label>location</label>                   <input type="text" class="form-control" required="required" id="usersecloc" maxlength="255" name="data[user][location]">                 <label id="userlocation-error" class="error" for="userlocation"></label>             </div>             <div class="form-group">                 <label>business name</label>                   <input type="text" class="form-control" required="required" id="userbusinessname" maxlength="255" name="data[user][business_name]">                 <label id="userbusiness-error" class="error" for="userbusinessname"></label>             </div>             <div class="form-group">                 <label for="userdocument">document</label>                      <select class="form-control" required="required" id="userdoc" name="data[user][document]">                     <option value="">-- select --</option>                     <option value="passport">passport</option>                     <option value="license certificate">license certificate</option>                      <option value="aggrement copy">aggrement copy</option>                 </select>                 <label id="examname-error" class="error" for="userdocument"> </label>             </div>             <!--<div class="form-group">                 <label>file input</label>                 <input type="file">             </div> -->             <div class="form-group" id="showdoc" style="display:none">                 <label>file</label>                  <!--<input name="data[document][docfile]" id="documentsubmittedfile" type="file"> -->                 <!--<input type="file" name="data[user][docfile]" id="usersfile"/>-->                 <?php //echo $this->form->input('doc_file',array( 'type' => 'file','error' => false,'placeholder'=>'upload image')); ?>                  <?php echo $this->form->file('document.submittedfile');  ?>              </div>             <div class="col-lg-12">                 <h4 class="page-header">point of contact</h4>              </div>             <div class="form-group">                 <label>name</label>                    <input type="text" class="form-control" required="required" id="pname" maxlength="255" name="data[user][pname]">                 <label id="userpname-error" class="error" for="userpname"></label>             </div>             <div class="form-group">                 <label>email</label>                                                       <input type="text" class="form-control" required="required" id="pemail" maxlength="255" name="data[user][pemail]">                 <label id="userpemail-error" class="error" for="userpemail"></label>             </div>             <div class="form-group">                 <label>phone</label>                   <input type="text" class="form-control" required="required" id="pphone" maxlength="255" name="data[user][pofc_phone]">                 <label id="userpphone-error" class="error" for="userpemail"></label>             </div>             <div class="form-group">                  <label>designation</label>                   <input type="text" class="form-control" required="required" id="pdesign" maxlength="255" name="data[user][pdesignation]">                  <label id="userpphone-error" class="error" for="userpdesign"></label>             </div>             <div class="form-group">                 <button type="submit" class="btn btn-default">next</button>              </div>         </form>     </div> </body>  

add quotes name rules: {"data[user][username]" :"required"


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -