gpt4 book ai didi

forms - CFML注册表单烦恼——encodeForHTMLAttribute的正确使用?

转载 作者:行者123 更新时间:2023-12-02 09:14:51 24 4
gpt4 key购买 nike

露西5.2

MS SQL Server 2014

嗨, friend 们,

我需要一些有关 CFML 任务的帮助 - 这是客户的 session 注册表。

在下面的代码中,我是否正确使用了encodeForHTMLAttribute?我一直在对encodeForHTMLAttribute进行一些研究——例如https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-e-g/encodeforhtmlattribute.html -- 但我不确定 a) 我是否正确使用它,或者 b) 我是否需要使用它。

下面的 CFML 看起来合理吗?一如既往地感谢您的帮助。

埃里克

<!--- begin CFOUTPUT for user input fields --->
<cfoutput>
<li>
<label for="Title"><h3>Title (Ms., Mr., Dr. etc.):</h3></label>
<input type="text" name="Title" placeholder="Title" value="#encodeForHTMLAttribute(Trim(Left(form.Title,255)))#" maxlength="255" tabindex="1" size="70" autofocus="true" />
</li>

<li>
<label for="x_first_name"><h3>First Name:</h3></label>
<input type="text" name="x_first_name" placeholder="First Name" value="#encodeForHTMLAttribute(Trim(Left(form.x_first_name,255)))#" maxlength="255" tabindex="2" size="70" required="yes" />
<span class="form_hint">Enter First Name</span>
</li>

<li>
<label for="MiddleInitial"><h3>Middle Initial:</h3></label>
<input type="text" name="MiddleInitial" placeholder="MI" value="#encodeForHTMLAttribute(Trim(Left(form.MiddleInitial,255)))#" maxlength="5" tabindex="3" size="1" />
</li>

<li>
<label for="x_last_name"><h3>Last Name:</h3></label>
<input type="text" name="x_last_name" placeholder="Last Name" value="#encodeForHTMLAttribute(Trim(Left(form.x_last_name,255)))#" maxlength="255" tabindex="4" size="70" required="yes" />
<span class="form_hint">Enter Last Name</span>
</li>

<li>
<label for="Credentials"><h3>Credentials:</h3></label>
<input type="text" name="Credentials" placeholder="Credentials (e.g. RN, MSN, PhD, MD)" value="#encodeForHTMLAttribute(Trim(Left(form.Credentials,255)))#" maxlength="255" tabindex="5" size="70" required="yes" />
<span class="form_hint">Credentials (e.g. RN, MSN, PhD, MD)</span>
</li>

<li>
<label for="x_company"><h3>Current Position and Organization:</h3></label>
<input type="text" name="x_company" placeholder="Current Position and Organization" value="#encodeForHTMLAttribute(Trim(Left(form.x_company,255)))#" maxlength="255" tabindex="6" size="70" required="yes" />
<span class="form_hint">Enter Current Position and Organization</span>
</li>

<li>
<label for="x_address"><h3>Address:</h3></label>
<input type="text" name="x_address" placeholder="Please enter your address" value="#encodeForHTMLAttribute(Trim(Left(form.x_address,255)))#" maxlength="255" tabindex="7" size="70" required="yes" />
<span class="form_hint">Please enter your mailing address</span>
</li>

<li>
<label for="x_city"><h3>City:</h3></label>
<input type="text" name="x_city" placeholder="Please enter your city" value="#encodeForHTMLAttribute(Trim(Left(form.x_city,255)))#" maxlength="255" tabindex="8" size="70" required="yes" />
<span class="form_hint">Please enter your city</span>
</li>

<li>
<label for="x_state"><h3>State or Province:</h3></label>
<input type="text" name="x_state" placeholder="Please enter your State or Province" value="#encodeForHTMLAttribute(Trim(Left(form.x_state,255)))#" maxlength="255" tabindex="9" size="70" required="yes" />
<span class="form_hint">Please enter your State or Province</span>
</li>


<li>
<label for="x_zip"><h3>ZIP or Postal Code:</h3></label>
<input type="text" name="x_zip" placeholder="Please enter your ZIP or Postal Code" value="#encodeForHTMLAttribute(Trim(Left(form.x_zip,25)))#" maxlength="255" tabindex="10" size="70" required="yes" />
<span class="form_hint">Please enter your ZIP or Postal Code</span>
</li>

<li>
<label for="x_country"><h3>Country:</h3></label>
<input type="text" name="x_country" placeholder="Please enter your country" value="#encodeForHTMLAttribute(Trim(Left(form.x_country,255)))#" maxlength="255" tabindex="11" size="70" required="yes" />
<span class="form_hint">Please enter your country</span>
</li>

<li>
<label for="TelephoneWork"><h3>Work Telephone:</h3></label>
<input type="text" name="TelephoneWork" placeholder="Please enter your work telephone number" value="#encodeForHTMLAttribute(Trim(Left(form.TelephoneWork,25)))#" maxlength="25" tabindex="13" size="70" />
<span class="form_hint">Please enter your work telephone number.</span>
</li>

<li>
<label for="x_email"><h3>email address:</h3></label>
<input type="text" name="x_email" placeholder="Important: Please enter your valid email address." value="#encodeForHTMLAttribute(Trim(Left(form.x_email,128)))#" maxlength="128" tabindex="16" size="70" required="yes" />
<span class="form_hint">Enter Email Address</span>
</li>

<li>
<label for="SpecialRequirements"><h3>Special Requirements -- dietary, mobility, etc.:</h3></label>

<input type="text" name="SpecialRequirements" placeholder="Important: Please enter special requirements, if any." value="#encodeForHTMLAttribute(Trim(Left(form.SpecialRequirements,255)))#"
maxlength="255" tabindex="18" size="70" />

</li>
</cfoutput><!--- /CFOUTPUT for user input fields --->

最佳答案

问题1

在表单字段中设置属性时使用的值。

encodeForHTMLAttribute()

问题2

美元的货币字段应为

type="number" step="0.01"

其他货币有不同的规模

问题3

您必须添加描述您的响应页面的代码。没有足够的信息来确定问题。

关于forms - CFML注册表单烦恼——encodeForHTMLAttribute的正确使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48119748/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com