Created createFormGroup functoin

This commit is contained in:
Pierre
2017-06-05 11:02:10 +02:00
parent 0d804dbdf7
commit be3b685429
3 changed files with 79 additions and 0 deletions

View File

@ -60,4 +60,36 @@ function emptyElem(container){
*/
function checkMail(emailAddress){
return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,5}$/) === null ? false : true);
}
/**
* Create a formgroup element
*
* @param {HTMLElement} target The target of the field
* @param {String} label The label of the field
* @param {String} placeholder The placeholder of the field
* @param {String} type The type of the field
* @return {HTMLElement} The input
*/
function createFormGroup(target, label, placeholder, type){
//Create formgroup
var formGroup = createElem("div", target);
formGroup.className = "form-group";
//Add label
var labelElem = createElem("label", formGroup);
labelElem.innerHTML = label;
//Create input group
var inputGroup = createElem("div", formGroup);
inputGroup.className = "input-group";
//Create input
var input = createElem("input", inputGroup);
input.type = type;
input.placeholder = placeholder;
//Return input
return input;
}