Jump to content
budimir

Jquery validation stoped working

Recommended Posts

I need you're help with jquery form validation. I have been using jguery form validation but when I have included ckeditor on the page validation stopped working. I can't figure out why. I'm not very good with javascript so it's hard for me to figure out what is blocking it.

 

Html form I'm using is:

<form action="save_costs.php" method="POST" role="form" id="form2">
										<div class="row">
											<div class="col-md-12">
												<div class="errorHandler alert alert-danger no-display">
													<i class="fa fa-times-sign"></i> You have some form errors. Please check below.
												</div>
												<div class="successHandler alert alert-success no-display">
													<i class="fa fa-ok"></i> Your form validation is successful!
												</div>
											</div>
											<div class="col-md-6">
												<div class="form-group">
													<label class="control-label">
														<?php if ($_SESSION['language'] == "English") { echo "Name"; } else if ($_SESSION['language'] == "Croatian") { echo "Naziv"; } ?> <span class="symbol required"></span>
													</label>
													<input type="text" placeholder="Insert name" class="form-control" id="name" name="name" />
												</div>
												<div class="form-group">
													<label class="control-label">
														<?php if ($_SESSION['language'] == "English") { echo "Description"; } else if ($_SESSION['language'] == "Croatian") { echo "Opis"; } ?> <span class="symbol required"></span>
													</label>
													<input type="text" placeholder="Insert description" class="form-control" id="description" name="description" />
												</div>
											</div>
											<div class="col-md-6">
												<div class="row">
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-md-12">
												<div class="form-group">
													<label class="control-label">
														<?php if ($_SESSION['language'] == "English") { echo "Comments"; } else if ($_SESSION['language'] == "Croatian") { echo "Komentari"; } ?>
													</label>
													<textarea class="ckeditor form-control" id="editor2" name="comment" cols="10" rows="10"></textarea>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-md-12">
												<div>
													<span class="symbol required"></span><?php if ($_SESSION['language'] == "English") { echo "Required Fields"; } else if ($_SESSION['language'] == "Croatian") { echo "Obavezna polja"; } ?>
													<hr />
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-md-8">
											</div>
											<div class="col-md-4">
												<button class="btn btn-primary btn-wide pull-right" type="submit">
													<?php if ($_SESSION['language'] == "English") { echo "Submit"; } else if ($_SESSION['language'] == "Croatian") { echo "Spremi"; } ?> <i class="fa fa-arrow-circle-right"></i>
												</button>
											</div>
										</div>
									</form>

Javascript file is attached.

 

This is how I initalise form validation and CKeditor.

<script src="../vendor/jquery/jquery.min.js"></script>
<script src="../vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="../vendor/ckeditor/ckeditor.js"></script>
<script src="../vendor/ckeditor/adapters/jquery.js"></script>
<script src="../items/js/article_validation.js"></script>
<script>
<script>
            jQuery(document).ready(function() {
                Main.init();
                FormValidator.init();
                CKEDITOR.instances."editor2".on('blur', function(){CKEDITOR.instances."editor2".updateElement();});
            });
        </script>

Can you, please, help me? I tried everything I thought it could block it.

 

I don't know what to do anymore.

Share this post


Link to post
Share on other sites

Ok, I managed to figure out that this part of code is blocking it:

CKEDITOR.instances."editor2".on('blur', function(){CKEDITOR.instances."editor2".updateElement();});

It is used for updating textarea on input and before submiting form. Why is it blocking validation?

Share this post


Link to post
Share on other sites

This isn't valid syntax:
 

 

CKEDITOR.instances."editor2"(...)

 

You'll get an error thrown for an unexpected string there. Assuming editor2 is a property of instances, then you can just use this:

 

 

CKEDITOR.instances.editor2(...)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.