Autor | Zpráva | ||
---|---|---|---|
janina hřebíková Profil * |
#1 · Zasláno: 22. 9. 2015, 17:57:04
Ahoj, mám formulář kde uživatel má vyplnit jméno. Problém je že se to odešle i když jméno nevyplní. Jak to udělat aby musel něco napsat do kolonky a jinak se to neodeslalo?
Mám to takto: <input name="a_name" type="text" value="" class="qa-form-tall-text"> |
||
Chamurappi Profil |
#2 · Zasláno: 22. 9. 2015, 17:59:05
Reaguji na janinu hřebíková:
Při události onsubmit na formuláři zkontroluj hodnotu:
<form onsubmit="if(!a_name.value) return false"> |
||
_es Profil |
#3 · Zasláno: 22. 9. 2015, 18:13:20
Chamurappi:
Ten kód je však závislý od toho, že to je v HTML atribúte. Aj tak si nie som celkom istý, či bude fungovať vo všetkých prehliadačoch. Ak bude ten kód vo funkcii priradenej v JS do onsubmit , tak nebude fungovať napríklad v Mozille.
|
||
janina hřebíková Profil * |
#4 · Zasláno: 22. 9. 2015, 18:54:04
Chamurappi:
A kam to mám dát prosím? function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors) { $in=array( 'name' => qa_post_text('a_name'), 'notify' => qa_post_text('a_notify') !== null, 'email' => qa_post_text('a_email'), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($question)) !== false, ); qa_get_post_content('a_editor', 'a_content', $in['editor'], $in['content'], $in['format'], $in['text']); $errors=array(); if (!qa_check_form_security_code('answer-'.$question['postid'], qa_post_text('code'))) $errors['content']=qa_lang_html('misc/form_security_again'); else { $filtermodules=qa_load_modules_with('filter', 'filter_answer'); foreach ($filtermodules as $filtermodule) { $oldin=$in; $filtermodule->filter_answer($in, $errors, $question, null); qa_update_post_text($in, $oldin); } if ($usecaptcha) qa_captcha_validate_post($errors); if (empty($errors)) { $testwords=implode(' ', qa_string_to_words($in['content'])); foreach ($answers as $answer) if (!$answer['hidden']) if (implode(' ', qa_string_to_words($answer['content'])) == $testwords) $errors['content']=qa_lang_html('question/duplicate_content'); } if (empty($errors)) { $userid=qa_get_logged_in_userid(); $handle=qa_get_logged_in_handle(); $cookieid=isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $answerid=qa_answer_create($userid, $handle, $cookieid, $in['content'], $in['format'], $in['text'], $in['notify'], $in['email'], $question, $in['queued'], $in['name']); return $answerid; } } return null; } |
||
_es Profil |
#5 · Zasláno: 23. 9. 2015, 12:57:30
|
||
Časová prodleva: 9 dní
|
|||
janina hřebíková Profil * |
#6 · Zasláno: 2. 10. 2015, 20:52:18
Omlouvám se ale nerozumím tomu. Kam to mám přidat? Děkuji
|
||
Časová prodleva: 8 let
|
0