form validation again

This commit is contained in:
Harry Bomrah 2012-08-13 18:45:02 +08:00 committed by Christophe Vilayphiou
parent ffa49fd092
commit 9ff60d2ba4
3 changed files with 10 additions and 2 deletions

View File

@ -26,14 +26,17 @@ $(document).on('click', '#ajax_form_submit', function(){
beforeSubmit: function(){
var sub = true;
$("span.error").remove();
$("#dyn_error").empty();
$("#ajaxForm input").each(function(){
if($(this).val() == ""){
$("<span class='error'>Cannot be empty.</span>").insertAfter($(this));
$("<span class='error'> *</span>").insertAfter($(this));
sub = false;
}
})
if(!sub)
if(!sub){
$("#dyn_error").text("Cannot be empty.");
return false;
}
},
success: function(response,status,xhr){
if(typeof tinyMCEPopup != "undefined"){

View File

@ -11,3 +11,7 @@
.warning{
color:orange;
}
label#dyn_error {
margin-left: 50%;
}

View File

@ -9,6 +9,7 @@
<div class="modal-header">
<h3><%= t 'admin.file_upload' %></h3>
</div>
<label class="control-label error" id="dyn_error"></label>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="title" class="control-label error"><%= t 'admin.title' %></label>