Problem with Validation plugin using ajax
Hi, I have a problem
when I submit form first time, everything is ok, and when I try to submit it once more, ajax is not working, and native form submit starting.
Here my code
js:
- $(document).ready(function(){
- $('#contacts_admin').validate(
- {
- rules:{
- "phone":{
- required:true
- },
- "email":{
- required:true,
- email:true
- },
- "slogan":{
- required:true
- },
- "adress":{
- required:true
- },
- "adress_bottom":{
- required:true
- },
- "worktime":{
- required:true
- },
- "map":{
- required:true
- }
- },
-
- messages:{
- "phone":{
- required:"Введите телефон"
- },
- "email":{
- required:"E-mail обязателен",
- email:"Пожалуйста, введите верный адрес электронной почты"
- },
- "slogan":{
- required:"Введите слоган в верхнем меню"
- },
- "adress":{
- required:"Введите адрес для самовывоза"
- },
- "adress_bottom":{
- required:"Введите адрес внизу страницы"
- },
- "worktime":{
- required:"Введите время работы"
- },
- "map":{
- required:"Вставьте код карты"
- }
- },
-
- submitHandler: function(form){
- $(form).ajaxSubmit({
-
- target: '#message',
- success: function(data) {
- clearForm: false,
- $('#message').fadeIn(),
- $('#message').html(data),
- setTimeout(function(){
- $('#message').fadeOut('slow')
- }, 2000);
- }
- });
- return false;
- }
- });
-
-
- });
html:
- <form id="contacts_admin" method="post" action="/admin/manage/contacts/update">
- <label class="col-sm-12 col-md-4">Телефон:</label>
- <div class="col-sm-12 col-md-8">
- <input class="form-control" type="text" name="phone" value="info">
- </div>
- <label class="col-sm-12 col-md-4">E-mail:</label>
- <div class="col-sm-12 col-md-8">
- <input class="form-control" type="email" name="email" value="info">
- </div>
- <label class="col-sm-12 col-md-4">Слоган в верхнем меню:</label>
- <div class="col-sm-12 col-md-8">
- <textarea class="form-control" name="slogan">info</textarea>
- </div>
- label class="col-sm-12 col-md-4">Адрес для самовывоза:</label>
- <div class="col-sm-12 col-md-8">
- <textarea class="form-control" name="adress">info</textarea>
- </div>
- <label class="col-sm-12 col-md-4">Адрес внизу страницы:</label>
- <div class="col-sm-12 col-md-8">
- <textarea class="form-control" name="adress_bottom">info</textarea>
- </div>
- <label class="col-sm-12 col-md-4">Время работы:</label>
- <div class="col-sm-12 col-md-8">
- <textarea class="form-control" name="worktime">info</textarea>
- </div>
- <label class="col-sm-12 col-md-4">Карта (код):</label>
- <div class="col-sm-12 col-md-8">
- <textarea class="form-control" name="map">info</textarea>
- </div>
-
- <div class="col-sm-12 col-md-8 col-sm-offset-4">
- <button id="contacts_admin_submit" class="btn btn-default">Сохранить</button>
- <button type="reset" class="btn btn-default">Отмена</button>
- </div>
-
- </form>