textarea是必填字段吗?

时间:2013-02-03 21:02:26

标签: javascript html forms textarea

我正在建立一个大型表格来编制我们客户(喜剧演员)的巡演时间表。 Seen here.

每当我删除底部较大的textarea时,表单就会停止工作,即。提交按钮不起作用。

为什么会发生这种情况?感谢。

我不知道究竟会有什么帮助,但这里是包含表单的div的代码:

<div class="info-avails">       

<form action="http://www.standupexperts.com/cgi-sys/formmail.pl" method="post" name="hgmailer" >
<input type="hidden" name="recipient" value="adam@standupexperts.com">
 <input type="hidden" name="subject" value="FormMail E-Mail">

                    <p> Name:<span style="color:white">X-</span>  <input type="text" name="name" size="20" value="">
                    <span style="color:white">X.X</span>Email: <input type="text" name="email" size="30" value=""><br />
                    Cell #: <span style="color:white">X.</span><input type="text" name="cell" size="20" value="">
                    Address:<span style="color:white">X</span><input type="text" name="address" size="30" value=""><br />
                    Website: <input type="text" name="website" size="20" value="">
                    Video Link:<input type="text" name="videolink" size="30" value=""><br />
                <!--    Tell us about your event. <br />  <textarea name="comment" cols="40" rows="6"></textarea> <br /> -->


                    </p>

            <div class="avails-method">
    <h3>
    Our avails method
    </h3>

If you cannot use the form below, you can <a href="mailto:adam.comedycaravan@gmail.com">email your schedule</a>. Use our notation system if you want your avails entered sooner.    

<a href="http://www.mediafire.com/file/wqyo8tpwq536048/2013_Comedy_Caravan_Avails_Sheet.doc">
                    Download</a> our 2013 avails sheet.
                    <br /><br />
For routing purposes, we want to know the dates you are NOT available and what state you'll be on those dates. <br /><br />

Below, <em>an X is already placed on open/available weeks</em>. For booked dates, please enter days booked and the state.

Example:<ul>
    <li>12-3: X (open)</li>
    <li>12-10: X 11-14 NC (open except the 10th thru 14th of Dec in NC)</li>
    <li>12-17: 19 OH, 22 IN (open except for the 19th of Dec in OH and the 22nd in IN)</li>
    <li>We are unable to work with <em>just</em> the day of the week (3/11: Thurs-Sun)</li>
    </ul>

                    </div> 
        <br class="clear" />                
    <h4>
    2013 Avails/Schedule
    </h4>


    <div class="year2013">
        <div class="jan-apr">

    1/07: <input type="text" name="1/07__" size="20" value="X"><br />
    1/14: <input type="text" name="1/14__" size="20" value="X"><br />    
    1/21: <input type="text" name="1/21__" size="20" value="X"><br />
    1/28: <input type="text" name="1/28__" size="20" value="X"><br />
    2/04: <input type="text" name="2/04__" size="20" value="X"><br />
    2/11: <input type="text" name="2/11__" size="20" value="X"><br />
    2/18: <input type="text" name="2/18__" size="20" value="X"><br />
    2/25: <input type="text" name="2/25__" size="20" value="X"><br />
    3/04: <input type="text" name="3/04__" size="20" value="X"><br />
    3/11: <input type="text" name="3/11__" size="20" value="X"><br />
    3/18: <input type="text" name="3/18__" size="20" value="X"><br />
    3/25: <input type="text" name="3/25__" size="20" value="X"><br />
    4/01: <input type="text" name="4/01__" size="20" value="X"><br />
    4/08: <input type="text" name="4/08__" size="20" value="X"><br />
    4/15: <input type="text" name="4/15__" size="20" value="X"><br />
    4/22: <input type="text" name="4/22__" size="20" value="X"><br />
    4/29: <input type="text" name="4/29__" size="20" value="X"><br />
    </div>
    <div class="may-aug">
    5/06: <input type="text" name="5/06__" size="20" value="X"><br />
    5/13: <input type="text" name="5/13__" size="20" value="X"><br />
    5/20: <input type="text" name="5/20__" size="20" value="X"><br />
    5/27: <input type="text" name="5/27__" size="20" value="X"><br />
    6/03: <input type="text" name="6/03__" size="20" value="X"><br />
    6/10: <input type="text" name="6/10__" size="20" value="X"><br />
    6/17: <input type="text" name="6/17__" size="20" value="X"><br />
    6/24: <input type="text" name="6/24__" size="20" value="X"><br />
    7/01: <input type="text" name="7/01__" size="20" value="X"><br />
    7/08: <input type="text" name="7/08__" size="20" value="X"><br />
    7/15: <input type="text" name="7/15__" size="20" value="X"><br />
    7/22: <input type="text" name="7/22__" size="20" value="X"><br />
    7/29: <input type="text" name="7/29__" size="20" value="X"><br />
    8/05: <input type="text" name="8/05__" size="20" value="X"><br />
    8/12: <input type="text" name="8/12__" size="20" value="X"><br />
    8/19: <input type="text" name="8/19__" size="20" value="X"><br />
    8/26: <input type="text" name="8/26__" size="20" value="X"><br />
    </div>
    <div class="sept-dec">
    9/02: <input type="text" name="9/02__" size="20" value="X"><br />
    9/09: <input type="text" name="9/09__" size="20" value="X"><br />
    9/16: <input type="text" name="9/16__" size="20" value="X"><br />
    9/23: <input type="text" name="9/23__" size="20" value="X"><br />
    9/30: <input type="text" name="9/30__" size="20" value="X"><br />
    10/07: <input type="text" name="10/07__" size="19" value="X"><br />
    10/14: <input type="text" name="10/14__" size="19" value="X"><br />
    10/21: <input type="text" name="10/21__" size="19" value="X"><br />
    10/28: <input type="text" name="10/28__" size="19" value="X"><br />
    11/04: <input type="text" name="11/04__" size="19" value="X"><br />
    11/11: <input type="text" name="11/11__" size="19" value="X"><br />
    11/18: <input type="text" name="11/18__" size="19" value="X"><br />
    11/25: <input type="text" name="11/25__" size="19" value="X"><br />
    12/02: <input type="text" name="12/02__" size="19" value="X"><br />
    12/09: <input type="text" name="12/09__" size="19" value="X"><br />
    12/16: <input type="text" name="12/16__" size="19" value="X"><br />
    12/23: <input type="text" name="12/23__" size="19" value="X"><br />
    NYE:<span style="color:white">..</span>   <input type="text" name="NYE__" size="19" value="X"><br />
    </div>
    </div><br class="clear" /> 
    <div class="commentsection">
    Anything else you want to add?<br />
    <textarea name="comment" cols="50" rows="6"></textarea>
    <input type="button" value="SUBMIT" onclick="hgsubmit();" >
    <input type="hidden" name="redirect" value="http://www.standupexperts.com">
  </div>
</form>
</div>

3 个答案:

答案 0 :(得分:2)

 else if (/\S+/.test(document.hgmailer.comment.value) == false)
   alert ("Your email content is needed.");

如果从表单中删除textarea,则document.hgmailer.comment不再存在,因此其.value会导致错误。因此,如果要删除textarea,还必须从JavaScript中删除此检查。

答案 1 :(得分:0)

formmail.pl可能需要一个注释字段,如果没有该注释字段,提交将无法通过验证并被忽略。

现在理想情况下,您可以修改formmail.pl以使此注释字段可选。您还可以删除文本区域并将其替换为<input type="hidden" name="comment" value="" />字段,该字段将包含每个提交的空注释字段。

### 有些偏离主题 ### 从表面上看,这种设置对我来说看起来不太安全。如果没有足够的安全性,这种形式可能最终被垃圾邮件发送者滥用。主要问题是目标电子邮件地址是从隐藏变量发送的,垃圾邮件发送者可以轻松修改。主题以及内容也来自表格。除非formmail.pl有一些反垃圾邮件措施,并且这些措施配置正确,否则您最好添加安全性或使用其他脚本。

没关系,我检查过,它只通过电子邮件发送本地地址,因此很少有垃圾邮件。

答案 2 :(得分:0)

在上面的html中,如果您将提交按钮<input>从按钮更改为submit.it不会停止。请在firebug或chrome element inspector中尝试此操作。

变化

<input type="button" value="SUBMIT" onclick="hgsubmit();" >

<input type="submit" value="SUBMIT" onclick="hgsubmit();" >

还编辑javascript以防止两次服务器requesttion.let html标记做的事情。