Jump to content
  • 0

Проблемы с jqBootstrapValidation валидацией


mstdmstd
 Share

Question

Всем привет,Есть форма с валидацией библиотеки ref

...



jQuery(document).ready(function ($) {

ShowCaptureImage();
$(".has-error").bind('change keypress', function () {

$(this).removeClass("has-error");
});

$("#register_username").focus();



$("input,textarea,select").jqBootstrapValidation(
{

preventSubmit: true,
submitError: function($form, event, errors) {

alert( "submitError errors::"+var_dump(errors) + " : " + (typeof errors) )

return true;

// Here I do nothing, but you could do something like display

// the error messages to the user, log, etc.

},
submitSuccess: function($form, event) {

alert("OK");

MakeOperatorRegister();

event.preventDefault();

},
filter: function() {

return $(this).is(":visible");

}

}
);



});

...

<!-- Register Form -->
<div class="row">

<div class=" col-sm-offset-2 col-sm-offset-right-2">

<h3>Enter your personal data and you will receive confirmation email soon.</h3>
<form role="form" class="form-horizontal" action="http://local-wprods.com/register" method="post" accept-charset="utf-8" id="form_register" name="form_register" enctype="multipart/form-data">

<input type="hidden" name="ci_csrf_token" value="" />

<div class="control-group form-group ">

<div class="controls">

<label for="register_username">Username</label>
<input class="form-control editable_field" type="text" id="register_username" name="register_username" value="Serge 1" size="20" maxlength="50" data-validation-required-message="Please enter your username." data-validation-ajax-ajax="http://local-wprods.com/main/register_check_username">
<p class="help-block">Would be checked if username is unique in system.</p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_email">Email</label>
<input class="form-control editable_field" type="text" id="register_email" name="register_email" value="nilov@com.ua2" size="20" maxlength="50" data-validation-required-message="Please enter your email." data-validation-ajax-ajax="http://local-wprods.com/main/register_check_email">
<p class="help-block">Would be checked if email is unique in system.</p>

</div>

</div>

<div class="control-group form-group ">

<div class="controls">

<label for="register_password">Password</label>
<input class="form-control editable_field" type="password" id="register_password" name="register_password" value="" size="20" maxlength="128" data-validation-required-message="Please enter your password." autocomplete="off">
<p class="help-block">Must be at least 6 chars.</p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_password_2">Confirm Password</label>
<input class="form-control editable_field" type="password" id="register_password_2" name="register_password_2" value="" size="20" maxlength="128" data-validation-required-message="Please enter your name confirm password." data-validation-matches-match="register_password" data-validation-matches-message="Must match password entered above" autocomplete="off" >
<p class="help-block">Must be equal Password field.</p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_first_name">First Name</label>
<input class="form-control editable_field" type="text" id="register_first_name" name="register_first_name" value="First Name3" size="32" maxlength="32" data-validation-required-message="Please enter your name first name.">
<p class="help-block"></p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_last_name">Last Name</label>
<input class="form-control editable_field" type="text" id="register_last_name" name="register_last_name" value="Last Name4" size="32" maxlength="32" data-validation-required-message="Please enter your name last name.">
<p class="help-block"></p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_company">Company Name</label>
<input class="form-control editable_field" type="text" id="register_company" name="register_company" value="Company5" size="32" maxlength="45">
<p class="help-block"></p>

</div>

</div>



<div class="control-group form-group ">

<div class="controls">

<label for="register_phone">Phone</label>
<input class="form-control editable_field" type="text" id="register_phone" name="register_phone" value="phone6" size="16" maxlength="16">
<p class="help-block"></p>

</div>

</div>

<div class="control-group form-group ">

<div class="controls">

<label for="register_user_url">Website</label>
<input class="form-control editable_field" type="text" id="register_user_url" name="register_user_url" value="http://user_url.com" size="100" maxlength="100">
<p class="help-block"></p>

</div>

</div>

<div class="control-group form-group ">

<div class="controls">

<label for="register_subscriber">Subscribe to email news about new products/blog articles</label>
<input class="editable_field" type="checkbox" id="register_subscriber" name="register_subscriber" value="1" >
<p class="help-block">Later you could to detail which notifications do you want to recieve.</p>

</div>

</div>

<div class="control-group form-group ">

<div class="controls">

<label for="register_i_agree">I agree to follow rules of site.</label>
<input class="editable_field" onclick="javascript:register_i_agreeonChange();" type="checkbox" id="register_i_agree" name="register_i_agree" value="1" >
<p class="help-block">To must check it to register.</p>

</div>

</div>







<div id="success"></div>
<!-- For success/fail messages -->

<section class="row disable-the-width col-md-offset-2-2 col-lg-offset-3-3">

<div class=" btn-group pull-right editor_btn_group " >

<div class="col-xs-6 ">

<button type="submit" id="btn_submit" class="btn btn-primary" >Submit</button>

</div>
<div class="col-xs-4">

<button type="reset" class="btn btn-cancel-action" onclick="javascript:document.location='http://local-wprods.com/home'" >

Home

</button>

</div>
<div class="col-xs-2">

<img src="http://local-wprods.com/static/images/modern-business/clear-data.png" alt="Clear All Data" title="Clear All Data" class="a_link img_clear_data" onclick="javascript:clearAllData()">

</div>

</div>

</section>

</form>

</div>

</div>
<!-- /.row →

А как правильно ?

...
Валидация работает но
1) Если неправильно заполнено 1 поле, то при нажатии сабмита красным цветом выделяются ВСЕ поля на форме, а не только поле с ошибкой как хотелось бы.
2) В полях имени пользователя и мейла прописаны обработчики для проверки на сервере data-validation-ajax-ajax= - но они не вызываются - в консоли вызова нет...

А как правильно?

Спасибо!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • 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. See more about our Guidelines and Privacy Policy