mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Improved groups creation form
This commit is contained in:
parent
28cb1e22e7
commit
f4e1b47d9d
@ -50,7 +50,7 @@ ComunicWeb.pages.groups.pages.create = {
|
|||||||
type: "div",
|
type: "div",
|
||||||
class: "submit-button-container"
|
class: "submit-button-container"
|
||||||
});
|
});
|
||||||
createElem2({
|
var submitButton = createElem2({
|
||||||
appendTo: submitContainer,
|
appendTo: submitContainer,
|
||||||
type: "input",
|
type: "input",
|
||||||
elemType: "submit",
|
elemType: "submit",
|
||||||
@ -61,14 +61,32 @@ ComunicWeb.pages.groups.pages.create = {
|
|||||||
//Handle form submit
|
//Handle form submit
|
||||||
formContainer.onsubmit = function(){
|
formContainer.onsubmit = function(){
|
||||||
|
|
||||||
|
//Check if a request is already pending
|
||||||
|
if(submitButton.disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
//Check user inputs
|
//Check user inputs
|
||||||
if(!ComunicWeb.common.formChecker.checkInput(nameInput, true)){
|
if(!ComunicWeb.common.formChecker.checkInput(nameInput, true)){
|
||||||
notify("Please specify the name of the group!", "danger");
|
notify("Please specify the name of the group!", "danger");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var name = nameInput.value;
|
||||||
|
|
||||||
|
//Check the length of the name of the group
|
||||||
|
if(name.length < 4){
|
||||||
|
notify("The name of the group is too short !", "danger");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disable submit button
|
||||||
|
submitButton.disabled = true;
|
||||||
|
|
||||||
//Perform a request on the server to create the group
|
//Perform a request on the server to create the group
|
||||||
ComunicWeb.components.groups.interface.create(nameInput.value, function(res){
|
ComunicWeb.components.groups.interface.create(name, function(res){
|
||||||
|
|
||||||
|
//Enable submit button
|
||||||
|
submitButton.disabled = false;
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(res.error){
|
if(res.error){
|
||||||
|
Loading…
Reference in New Issue
Block a user