mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-28 01:36:33 +08:00
setup experiment modal input validation
This commit is contained in:
parent
9440371f3f
commit
de6c03a73b
2 changed files with 19 additions and 3 deletions
|
@ -1,9 +1,10 @@
|
|||
|
||||
(function(){
|
||||
|
||||
// Create ajax hook on given 'element', which should return modal with 'id' =>
|
||||
// show that modal
|
||||
function initializeModal(element, id){
|
||||
|
||||
// Initializev new experiment modal listner
|
||||
$(element)
|
||||
.on("ajax:beforeSend", function(){
|
||||
animateSpinner();
|
||||
|
@ -15,6 +16,7 @@
|
|||
keyboard: false,
|
||||
});
|
||||
validateMoveModal(id);
|
||||
validateExperimentForm();
|
||||
})
|
||||
.on("ajax:error", function() {
|
||||
animateSpinner(null, false);
|
||||
|
@ -63,6 +65,14 @@
|
|||
})
|
||||
.clearFormErrors();
|
||||
}
|
||||
// Setup front-end validations for experiment form
|
||||
function validateExperimentForm(){
|
||||
var form = $("#new-experiment-modal").find("form");
|
||||
form.on('submit', function(ev){
|
||||
textValidator(ev, $('#new-experiment-name'), false);
|
||||
textValidator(ev, $('#new-experiment-description'), true);
|
||||
});
|
||||
form.clearFormErrors();
|
||||
}
|
||||
// Initialize no description edit link
|
||||
function initEditNoDescription(){
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="form-group">
|
||||
<%= form.text_field :name, label: t("experiments.new.name"), autofocus: true, placeholder: t("experiments.new.name_placeholder") %>
|
||||
<%= form.text_field :name,
|
||||
label: t("experiments.new.name"),
|
||||
autofocus: true,
|
||||
placeholder: t("experiments.new.name_placeholder"),
|
||||
id: 'new-experiment-name'%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -9,7 +13,9 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="form-group">
|
||||
<%= form.text_area :description, label: t('experiments.new.description') %>
|
||||
<%= form.text_area :description,
|
||||
label: t('experiments.new.description'),
|
||||
id: 'new-experiment-description' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue