Files
selima-perl/htdocs/htc/scripts/guestbook.js
2026-03-10 21:31:43 +08:00

56 lines
1.8 KiB
JavaScript

/* History: Theory and Culture
* guestbook.js: The guestbook-related JavaScript subroutines.
*/
/* Copyright (c) 2000-2018 imacat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Author: imacat <imacat@mail.imacat.idv.tw>
* First written: 2000-07-25
*/
// isGuestbookOK: Check if the message is ready to be submitted
function isGuestbookOK(form) {
// Regularize the fields
form.message.value = trimText(form.message.value);
form.name.value = trim(form.name.value);
form.identity.value = trim(form.identity.value);
form.location.value = trim(form.location.value);
form.email.value = trim(form.email.value);
form.url.value = trim(form.url.value);
// Check the message
if (form.message.value == "" || form.message.value == _("Fill in your message here.")) {
alert(_("Please fill in your message."));
form.message.focus();
return false;
}
if (form.message.value.length > 10240) {
alert(_("Your message is too long. (Max. 10,240 letters)"));
form.message.focus();
return false;
}
// Check the signature
if (form.name.value == "") {
alert(_("Please fill in your signature."));
form.name.focus();
return false;
}
return true;
}