Начало
Формы
Предложения
Используйте JavaScript, чтобы позволить посетителям посылать Вашу обратную связь
Enter your name:
Browser/Version:
Enter your suggestion(s):
JavaScript Forms: Предложения
<!-- THREE STEPS TO INSTALL SUGGESTIONS: 1. Paste the coding into the HEAD of your HTML document 2. Add the onLoad event handler to the BODY tag 3. Put the last code into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin function leaptoIntro() { window.location="http://javascriptlist.narod.ru" } function About() { alert("\nHave a suggestion for a JavaScript example?\n\nFill out the form and submit it. I will see what I can do.\n\nPlease be as specific as possible."); document.forms[0].elements[1].focus(); } function Reset() { document.forms[0].elements[1].value = ""; document.forms[0].elements[2].value = navigator.appName + " " + navigator.appVersion; document.forms[0].elements[3].value = ""; document.forms[0].elements[1].focus(); } function submitForm() { if ( (isName() ) && (isBrowser()) && (isSuggestion()) ) { if (confirm("\nYour submission is about to be sent.\n\nClick YES to submit.\n\nClick NO to cancel.")) return true else return false; } else return false; } function isName() { var str = document.forms[0].elements[1].value; if (str == "") { alert("\nThe NAME field is blank.\n\nPlease enter your name.") document.forms[0].elements[1].focus(); return false; } for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i + 1); if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' ') { alert("\nThe NAME field only accepts letters & spaces.\n\nPlease re-enter your name."); document.forms[0].elements[1].select(); document.forms[0].elements[1].focus(); return false; } } return true; } function isBrowser() { if (document.forms[0].elements[2].value != navigator.appName + " " + navigator.appVersion) { if (confirm("\nYou've changed your browser type.\n\nClick YES to keep changes.\n\nClick NO to restore detected browser.")) return true else { document.forms[0].elements[2].value = navigator.appName + " " + navigator.appVersion; return true; } } else return true; } function isSuggestion() { var str = document.forms[0].elements[3].value; if (str == "") { alert("\nThe SUGGESTION field is blank.\n\nPlease enter your suggestion.") document.forms[0].elements[3].focus(); return false; } else return true } // End --> </SCRIPT> <!-- STEP TWO: Add this onLoad event handler to the BODY tag --> <BODY onLoad="Reset()"> <!-- STEP THREE: Copy this code into the BODY your HTML document --> <CENTER> <FORM ENCTYPE="text/plain" NAME="test" METHOD='POST' ACTION='mailto:you@yourdomain.com?subject=JS Suggestions' onSubmit="return submitForm()"> <INPUT TYPE="hidden" NAME="form1" VALUE="JS Suggestions"> <TABLE BORDER=0 WIDTH=564> <TR> <TD align="center"> <FONT><STRONG>Enter your name:</STRONG></FONT> <TD align="center"> <FONT><STRONG>Browser/Version:</STRONG></FONT> </TR> <TR> <TD align="center"> <INPUT TYPE="text" NAME="name" SIZE=26 MAXLENGTH=40> <TD align="center"> <INPUT TYPE="text" NAME="browser" SIZE=26 MAXLENGTH=40> </TR> </TABLE> <BR> <TABLE BORDER=0> <TR> <TD align="center"> <FONT><STRONG>Enter your suggestion(s):</STRONG></FONT> </TR> <TR> <TD align="center"><TEXTAREA NAME="suggestions" ROWS=2 COLS=55 wrap=yes></TEXTAREA> </TR> </TABLE> <BR><BR> <TABLE BORDER=0 WIDTH=300> <TR> <TD align="center"><INPUT TYPE="submit" VALUE="Submit"> <TD align="center"><INPUT TYPE="reset" VALUE="Reset" onClick="Reset()"> <TD align="center"><INPUT TYPE="button" VALUE="About" onClick="About()"> <TD align="center"><INPUT NAME="update" TYPE="BUTTON" VALUE="Close" OnClick="leaptoIntro()"> </TR> </TABLE> </FORM> </CENTER> <!-- Script Size: 3.82 KB -->