56 lines
2.2 KiB
JavaScript
56 lines
2.2 KiB
JavaScript
/* Woman's Voice
|
|
* 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-06-07
|
|
*/
|
|
|
|
// 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;
|
|
}
|
|
message = form.message.value.toLowerCase();
|
|
if (message.indexOf("<a href=") != -1 || message.indexOf("<table") != -1) {
|
|
return confirm(_("Your message contains HTML, which will be displayed \"AS IS\". If this is a commercial advertisement, it will be deleted right away and you are wasting your time. Do you still want to submit this message?"));
|
|
}
|
|
if (message.indexOf("[url=") != -1) {
|
|
return confirm(_("Your message contains BBCode, which will be displayed \"AS IS\". If this is a commercial advertisement, it will be deleted right away and you are wasting your time. Do you still want to submit this message?"));
|
|
}
|
|
|
|
return true;
|
|
}
|