You are invited to Log in or Register a free Frihost Account!

Application form - onSubmit='return false;

Heya, is there any chance to disable ENTER button while filling a textbox in application?
I've already done it using onSubmit='return false; in form start but I've spotted Submin button at the bottom of the application doesn't work aswell.

Here's the code:

| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| Filename: application.php
| Author: Starefossen
| Form is made on request by Starefossen.
| No warranty is given, please visit the PHP-Fusion
| MODs & Infusions site for help :)
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
require_once "maincore.php";
require_once THEMES."templates/header.php";

if (!iMEMBER) { redirect(BASEDIR."index.php"); }

|                APPLICATION SETTINGS             |
$form_settings['name']            = "Application Form";   // This will be the name of the Application Form
$form_settings['desc']            = "Please fill completely this application. It will be automatically posted on the forums.";

$form_settings['subject_key']      = "form_character_name,_specialization_and_class";         // This will be the form input which is used as subject.
$form_settings['subject_prefix']    = "Application: ";    // This will come right before the subject. Set this to blank if not needed.
$form_settings['forum_id']          = "7";               // This will be the forum the thread is posted in.

|                APPLICATION FORM                |
   EG: <input type='text' class='textbox' name='form_name' style='width:250px;' />
function application_form($country_opts) {
   global $form_settings;
   // Start Form
   echo "<form onSubmit='return false;' action='".FUSION_SELF."' method='post'>";
   echo "<table class='tbl-border' width='100%'>\n<tr>\n";
   echo "<td class='tbl1' colspan='2'>".$form_settings['desc']."</td>\n";
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>A. Basic Information </strong></td>\n";
   // Name Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Name: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_name' style='width:370px;' /></td>\n";
   // Age Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Age: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_age' style='width:370px;' /></td>\n";
   // Gender Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Gender: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_gender' style='width:370px;' /></td>\n";
   // Country Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Country: </td>\n";
      echo "<td class='tbl1'><select class='textbox' name='form_country' style='width:370px;'>$country_opts</select></td>\n";
   // Occupation
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Occupation: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_occupation' style='width:370px;' /></td>\n";
   // Yourself
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Tell us a little bit about yourself: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_tell_us_a_little_bit_about_yourself' style='height:40px; width:370px;' /></td>\n";
   // Playtime
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>How long have you played WoW? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_how_long_have_you_played_wow' style='width:370px;' /></td>\n";
   // Playtime 2
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Total time played on this character: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_total_time_played_on_this_character' style='width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>B. System Information </strong></td>\n";
   // System specs
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>System specs: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_system_specs' style='width:370px;' /></td>\n";
   // Microphone
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you have a microphone? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_a_microphone' style='width:370px;' /></td>\n";
   // Vetrilo
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Can you use Ventrilo? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_can_you_use_ventrilo' style='width:370px;' /></td>\n";
   // Disconnects
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you have any disconnection problem at all? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_any_disconnection_problems_at_all' style='width:370px;' /></td>\n";
   // FPS
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Average FPS in raid during a boss encounter? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_avarage_fps_in_raid_during_a_boss_encounter' style='width:370px;' /></td>\n";
   // Ping
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Average latency while raiding? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_avarage_latency_during_raiding' style='width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>C. Raiding and Character Information </strong></td>\n";
   // Character
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Character Name - Spec Class: <br><u>(example: Saarg - Protection Warrior)</u></td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_character_name,_specialization_and_class' style='width:370px;' /></td>\n";
   // Armory
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Armory Link: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_armory_link' style='width:370px;' /></td>\n";
   // Sons of Hodir
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Are you exalted with Sons of Hodir? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_are_you_exalted_with_sons_of_hodir' style='width:370px;' /></td>\n";
   // Vanilla WoW EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Vanilla WoW experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_vanilla_wow_experience' style='height:40px; width:370px;' /></td>\n";
   // TBC EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>The Burning Crusade experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_the_burning_crusade_experience' style='height:40px; width:370px;' /></td>\n";
   // WotLK EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Wrath of the Lich King experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_wrath_of_the_lich_king_experience' style='height:40px; width:370px;' /></td>\n";
   // Leader
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Have you ever been a raidleader or guildmaster? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_have_you_ever_been_a_raidleader_or_guildmaster' style='height:40px; width:370px;'/></td>\n";
   // Elixirs
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Do you have the will and time to put in enough effort flasks and consumables for the raid? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_the_will_and_time_to_put_in_enough_effort_flasks_and_consumables_for_the_raid' style='height:40px; width:370px;' /></td>\n";
   // Tactics
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Will you come to a progression raid having already read any available information relevant to encounters? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_will_you_come_to_a_progression_raid_having_already_read_any_available_information_relevant_to_encounters' style='height:40px; width:370px;' /></td>\n";
   // Raidtime
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>What do you think about beginning raids early and staying beyond the required raid times to down new content? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_do_you_think_about_beginning_raids_early_and_staying_beyond_the_required_raid_times_to_down_new_content' style='height:40px; width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>D. Other Questions </strong></td>\n";
   // Current guild
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>What guild are you currently in? Who is/was the GM? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_guild_are_you_currently_in_?_Who_is/was_the_GM' style='height:40px; width:370px;' /></td>\n";
   // Current guild history
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Why are you leaving your current guild? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_why_are_you_leaving_your_current_guild' style='height:40px; width:370px;' /></td>\n";
   // Activity
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Do you play actively outside of raiding? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_play_actively_outside_of_raiding' style='height:40px; width:370px;' /></td>\n";
   // Bench time
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>There will be Bench time. Everyone will have to sit at one point in time or another. Are you okay with this? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_there_will_be_Bench_time._everyone_will_have_to_sit_at_one_point_in_time_or_another._Are_you_okay_with_this' style='height:40px; width:370px;' /></td>\n";
   // Interested in joining
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Why are you interested in joining Duality? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_why_are_you_interested_in_joining_duality' style='height:40px; width:370px;' /></td>\n";
   // Referaals
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>Do you currently know anyone in Duality? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_currently_know_anyone_in_duality' style='height:40px; width:370px;' /></td>\n";
   // Referaals
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1' valign='top'>What kind of raider can we expect you to be? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_kind_of_raider_can_we_expect_you_to_be' style='height:40px; width:370px;' /></td>\n";
   // Submit Form
   echo "</tr>\n<tr>\n";
   echo "<td class='tbl1'></td>\n";
   echo "<td class='tbl1'>";
   echo "<input type='submit' class='button' name='submit_form' value='Submit' />\n";
   echo "<input type='reset' class='button' name='reset_form' value='Reset' /></td>\n";
   echo "</tr>\n</table>\n</form>\n";

|             NO EDIT BELLOW THIS NEEEDED             |
if (!function_exists("stripos")) {
   function stripos($haystack, $needle){
       return strpos($haystack, stristr( $haystack, $needle ));

if (isset($_POST['submit_form'])) {
   $message = "";
   $subject = "Unknown Name";
   while (list($key, $value) = each($_POST)) {
      if (stripos($key, "form_") === 0) {
         if ($key == $form_settings['subject_key']) {
            $subject = $form_settings['subject_prefix'].stripinput($value);
         $new_key = str_replace("form_", "", $key);
         $new_key = str_replace("_", " ", $new_key);
         $new_key = ucfirst(strtolower($new_key));
         $message .= "[b]$new_key:[/b]\n".stripinput($value)."\n\n";
   $result = dbquery("INSERT INTO ".DB_THREADS." (
   ) VALUES (
   $thread_id = mysql_insert_id();
   $result = dbquery("INSERT INTO ".DB_POSTS." (
   ) VALUES (
   $post_id = mysql_insert_id();
   $result = dbquery("UPDATE ".DB_FORUMS." SET forum_lastpost='".time()."', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastuser='".$userdata['user_id']."' WHERE forum_id='".$form_settings['forum_id']."' LIMIT 1");
   $result = dbquery("UPDATE ".DB_THREADS." SET thread_lastpostid='".$post_id."' WHERE thread_id='".$thread_id."' LIMIT 1");
   $result = dbquery("UPDATE ".DB_USERS." SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."' LIMIT 1");

$country_list = array(
   "Antigua and Barbuda",
   "Bosnia and Herzegovina",
   "Burkina Faso",
   "Cape Verde",
   "Central African Republic",
   "Congo (Brazzaville)",
   "Costa Rica",
   "Cote d'Ivoire",
   "Czech Republic",
   "Dominican Republic",
   "East Timor (Timor Timur)",
   "El Salvador",
   "Equatorial Guinea",
   "Gambia, The",
   "Korea, North",
   "Korea, South",
   "Marshall Islands",
   "New Zealand",
   "Papua New Guinea",
   "Saint Kitts and Nevis",
   "Saint Lucia",
   "Saint Vincent",
   "San Marino",
   "Sao Tome and Principe",
   "Saudi Arabia",
   "Serbia and Montenegro",
   "Sierra Leone",
   "Solomon Islands",
   "South Africa",
   "Sri Lanka",
   "Trinidad and Tobago",
   "United Arab Emirates",
   "United Kingdom",
   "United States",
   "Vatican City",

$country_opts = ""; $sel = ""; $selected = "";
while(list($key, $country) = each($country_list)){
   $sel = ($country == $selected ? " selected='selected'" : "");
   $country_opts .= "<option".$sel.">".$country."</option>\n";

opentable("Application Form");

echo "<!-- Application From Made by Starefossen @ <a href=''></a> -->";

require_once THEMES."templates/footer.php";

Asis wrote:
Heya, is there any chance to disable ENTER button while filling a textbox in application?
I've already done it using onSubmit='return false; in form start but I've spotted Submin button at the bottom of the application doesn't work aswell.

<input type="text" value="Type here" onkeydown="if (event.keyCode == 13) {return false;}" />
Thanks for answer. Where should I paste this?
Asis wrote:
Thanks for answer. Where should I paste this?

1. remove the onsubmit="return false" because this will block the submition of the form
echo "<form onSubmit='return false;' action='".FUSION_SELF."' method='post'>";

onkeydown="if (event.keyCode == 13) {return false;}"

to ALL text input fields where you want to block the enter key

  // Name Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Name: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_name' style='width:370px;'  onkeydown=\"if (event.keyCode == 13) {return false;}\" /></td>\n";

3. visit W3schools, learn the basics of (x)HTML and forms, it will help you in the future.

the principle of: "give a man a fish and you will feed him for a for a day, teach him how to catch fish and you feed him for a lifetime"
Related topics
Web Mailer, Create a "contact us" mailer
How do i make "_derived/nortbots.htm"??
subject javascript code please help
javascript function not being seen
SOS Guys I realy need ur help!
[*RESOLVED*] Please close for me.
Javascript onSubmit
AJAX tutorial [2nd part now updated]
File upload problem :'(
For those who need a contact form
help on a drop down menu!! Please Read!!
Required Field Question
Application form - getting rid of ucwords
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.