Maxlength for inputs

This commit is contained in:
Tobias Reich 2014-02-02 23:56:20 +01:00
parent 88c8108035
commit 62c26b9153
5 changed files with 16 additions and 14 deletions

View File

@ -117,7 +117,7 @@ album = {
}], }],
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
modal.show("New Album", "Please enter a title for this album: <input class='text' type='text' placeholder='Title' value='Untitled'>", buttons); modal.show("New Album", "Please enter a title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='Untitled'>", buttons);
}, },
@ -232,8 +232,8 @@ album = {
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
if (albumIDs.length===1) modal.show("Set Title", "Please enter a new title for this album: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons); if (albumIDs.length===1) modal.show("Set Title", "Please enter a new title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
else modal.show("Set Titles", "Please enter a title for all " + albumIDs.length + " selected album: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons); else modal.show("Set Titles", "Please enter a title for all " + albumIDs.length + " selected album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
}, },
@ -249,7 +249,7 @@ album = {
description = $(".message input.text").val(); description = $(".message input.text").val();
if (description.length<800) { if (description.length<801) {
if (visible.album()) { if (visible.album()) {
album.json.description = description; album.json.description = description;
@ -268,7 +268,7 @@ album = {
}], }],
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
modal.show("Set Description", "Please enter a description for this album: <input class='text' type='text' placeholder='Description' value='" + oldDescription + "'>", buttons); modal.show("Set Description", "Please enter a description for this album: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
}, },

View File

@ -171,8 +171,8 @@ photo = {
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
if (photoIDs.length===1) modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons); if (photoIDs.length===1) modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
else modal.show("Set Titles", "Please enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' placeholder='Title' value=''>", buttons); else modal.show("Set Titles", "Please enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>", buttons);
}, },
@ -299,7 +299,7 @@ photo = {
}], }],
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
modal.show("Set Description", "Please enter a description for this photo: <input class='text' type='text' placeholder='Description' value='" + oldDescription + "'>", buttons); modal.show("Set Description", "Please enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
}, },
@ -322,7 +322,7 @@ photo = {
}], }],
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
modal.show("Set Tags", "Please enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' placeholder='Tags' value='" + oldTags + "'>", buttons); modal.show("Set Tags", "Please enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
}, },

View File

@ -13,7 +13,7 @@ function addAlbum($title) {
global $database; global $database;
if (strlen($title)<1||strlen($title)>30) return false; if (strlen($title)<1||strlen($title)>50) return false;
$sysdate = date("d.m.Y"); $sysdate = date("d.m.Y");
$result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');"); $result = $database->query("INSERT INTO lychee_albums (title, sysdate) VALUES ('$title', '$sysdate');");
@ -193,7 +193,7 @@ function setAlbumTitle($albumIDs, $title) {
global $database; global $database;
if (strlen($title)<1||strlen($title)>30) return false; if (strlen($title)<1||strlen($title)>50) return false;
$result = $database->query("UPDATE lychee_albums SET title = '$title' WHERE id IN ($albumIDs);"); $result = $database->query("UPDATE lychee_albums SET title = '$title' WHERE id IN ($albumIDs);");
if (!$result) return false; if (!$result) return false;
@ -206,7 +206,7 @@ function setAlbumDescription($albumID, $description) {
global $database; global $database;
$description = htmlentities($description); $description = htmlentities($description);
if (strlen($description)>800) return false; if (strlen($description)>1000) return false;
$result = $database->query("UPDATE lychee_albums SET description = '$description' WHERE id = '$albumID';"); $result = $database->query("UPDATE lychee_albums SET description = '$description' WHERE id = '$albumID';");
if (!$result) return false; if (!$result) return false;

View File

@ -108,7 +108,7 @@ function setPhotoTitle($photoIDs, $title) {
global $database; global $database;
if (strlen($title)>30) return false; if (strlen($title)>50) return false;
$result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($photoIDs);"); $result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($photoIDs);");
if (!$result) return false; if (!$result) return false;
@ -121,7 +121,7 @@ function setPhotoDescription($photoID, $description) {
global $database; global $database;
$description = htmlentities($description); $description = htmlentities($description);
if (strlen($description)>800) return false; if (strlen($description)>1000) return false;
$result = $database->query("UPDATE lychee_photos SET description = '$description' WHERE id = '$photoID';"); $result = $database->query("UPDATE lychee_photos SET description = '$description' WHERE id = '$photoID';");
if (!$result) return false; if (!$result) return false;

View File

@ -27,6 +27,8 @@ function setTags($photoIDs, $tags) {
// Parse tags // Parse tags
$tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags); $tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags);
$tags = preg_replace('/,$|^,/', ',', $tags); $tags = preg_replace('/,$|^,/', ',', $tags);
if (strlen($tags)>1000) return false;
$result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);"); $result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);");