私は自分自身が完全に途方に暮れていて、新鮮な目が必要なので、これを求めています。
次のJavaScript関数は、接続されたHTMLフォームの送信時に正常に呼び出されます。関数が開始され、最初の2つのif
ステートメントが実行されます(返される場合は送信を停止しfalse
ます)。
alert
次に、 「前」の最初のテストが表示され、フォームが送信され、残りの関数が完全に欠落します。テスト中にfalse
、関数が何が起こっても返されるように最終行を返すように変更しましfalse
たが、フォームはまだ送信されています。
function validateForm(form)
{
// declare variables linked to the form
var _isbn = auto.isbn.value;
var _idisplay = auto.isbn.title;
var _iref = "1234567890X";
// call empty string function
if (EmptyString(_isbn,_idisplay)==false) return false;
// call check against reference function
if (AgainstRef(_isbn,_iref,_idisplay)==false) return false;
// call check length function
alert("before");///test alert
////// FORM SUBMITS HERE?!? /////////////
if (AutoLength(_isbn)==false) return false;
alert("after");///test alert
// if all conditions have been met allow the form to be submitted
return true;
}
編集:これはAutoLength
次のようになります:
function AutoLength(_isbn) {
if (_isbn.length == 13) {
return true; {
else {
if (_isbn.length == 10) {
return true; {
else {
alert("You have not entered a valid ISBN10 or ISBN13. Please correct and try again.");
return false;
}
}