问题描述
我正在努力做到这一点,以便我的HTML表单仅接受拉丁字母中的字符.该网站是中东潜在客户经常光顾的地方,但他们经常用阿拉伯语或东亚语言字符输入.我试图使用网络上其他地方找到的代码,但无济于事.我在下面粘贴了我的表单代码.我该怎么做呢?它将粘贴到Wix网站上的iFrame中.
I am looking to make it so that my HTML form will only accept characters from the Latin alphabet. The site is frequented by potential clients in the Middle East but they often type in Arabic or with characters from East Asian languages. I have tried to use code found elsewhere on the web but to no avail. I have pasted my form code below. How can I make this so? It is pasted within an iFrame on a Wix website.
谢谢.
<font face="helvetica" <META HTTPS-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://example.example.com/servlet/servlet.example?encoding=UTF-8" method="POST" target='_parent'>
<input type=hidden name="oid" value="00D0Y0000034cvq">
<input type=hidden name="retURL" value="https://example.com/successful-registration">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="[email protected]"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label> <input id="first_name" maxlength="40" name="first_name" size="20" type="text" required=true/><br><br>
<label for="middle_name">Middle Name</label> <input id="middle_name" maxlength="80" name="middle_name" size="20" type="text" /><br><br>
<label for="last_name">Last Name</label> <input id="last_name" maxlength="80" name="last_name" size="20" type="text" required=true /><br><br> Date of Birth: <span class="dateInput dateOnlyInput"> <input id="00N0Y00000RWiNa" name="00N0Y00000RWiNa" size="12" type="text" name="inputBox" placeholder=" DD/MM/YYY" /></span><br><br>
<label for="city">City</label> <input id="city" maxlength="40" name="city" size="20" type="text" /><br><br>
<label for="country_code">Country</label> <select id="country_code" name="country_code"><option value="">--None--</option><option value="BH">Bahrain</option>
<option value="EG">Egypt</option>
<option value="JO">Jordan</option>
<option value="KW">Kuwait</option>
<option value="LB">Lebanon</option>
<option value="MA">Morocco</option>
<option value="OM">Oman</option>
<option value="OTHER">Other</option>
<option value="QA">Qatar</option>
<option value="SA">Saudi Arabia</option>
<option value="SY">Syria</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
</select><br><br>
<label for="mobile">Mobile</label> <input id="mobile" maxlength="40" name="mobile" size="20" type="text" required=true/><br><br>
<label for="email">Email</label> <input id="email" pattern="[^ @]*@[^ @]*" maxlength="80" name="email" size="20" type="text" required=true /><br><br> Current/Previous School/University: <input id="00N0Y00000RWiNZ" maxlength="100"
name="00N0Y00000RWiNZ" size="20" type="text" /><br><br> Course you would like to study: <input id="00N0Y00000RWiNi" maxlength="255" name="00N0Y00000RWiNi" size="20" type="text" /><br><br>
<label for="lead_source">Where did you hear about us?</label> <select id="lead_source" name="lead_source"><option value="">--None--</option>
<option value="Instagram">Instagram</option>
<option value="Facebook">Facebook</option>
<option value="Twitter">Twitter</option>
<option value="Google">Google</option>
<option value="School Counsellor_(Please specify)">School Counsellor_(Please specify)</option>
<option value="University Website_(Please specify)">University Website_(Please specify)</option>
<option value="Web">Web</option>
</select><br><br>
<input type=hidden id="00N0Y00000RWvPA" name="00N0Y00000RWvPA" type="checkbox" value="1" />
<center><input type="submit" name="submit"></center>
</form>
推荐答案
检查此代码段.我在form元素中添加了以下更改作为属性.
Check this code snippet. I have added the following change in the form element as an attribute.
accept-charset="ISO-8859-1"
ISO-8859-1-拉丁字母的字符编码.
ISO-8859-1 - Character encoding for the Latin alphabet.
参考: https://www.w3schools.com/charsets/ref_html_8859.asp
<font face="helvetica" <META HTTPS-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://example.example.com/servlet/servlet.example?encoding=UTF-8" method="POST" target='_parent' accept-charset="ISO-8859-1">
<input type=hidden name="oid" value="00D0Y0000034cvq">
<input type=hidden name="retURL" value="https://example.com/successful-registration">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="[email protected]"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label> <input id="first_name" maxlength="40" name="first_name" size="20" type="text" required=true/><br><br>
<label for="middle_name">Middle Name</label> <input id="middle_name" maxlength="80" name="middle_name" size="20" type="text" /><br><br>
<label for="last_name">Last Name</label> <input id="last_name" maxlength="80" name="last_name" size="20" type="text" required=true /><br><br> Date of Birth: <span class="dateInput dateOnlyInput"> <input id="00N0Y00000RWiNa" name="00N0Y00000RWiNa" size="12" type="text" name="inputBox" placeholder=" DD/MM/YYY" /></span><br><br>
<label for="city">City</label> <input id="city" maxlength="40" name="city" size="20" type="text" /><br><br>
<label for="country_code">Country</label> <select id="country_code" name="country_code"><option value="">--None--</option><option value="BH">Bahrain</option>
<option value="EG">Egypt</option>
<option value="JO">Jordan</option>
<option value="KW">Kuwait</option>
<option value="LB">Lebanon</option>
<option value="MA">Morocco</option>
<option value="OM">Oman</option>
<option value="OTHER">Other</option>
<option value="QA">Qatar</option>
<option value="SA">Saudi Arabia</option>
<option value="SY">Syria</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
</select><br><br>
<label for="mobile">Mobile</label> <input id="mobile" maxlength="40" name="mobile" size="20" type="text" required=true/><br><br>
<label for="email">Email</label> <input id="email" pattern="[^ @]*@[^ @]*" maxlength="80" name="email" size="20" type="text" required=true /><br><br> Current/Previous School/University: <input id="00N0Y00000RWiNZ" maxlength="100"
name="00N0Y00000RWiNZ" size="20" type="text" /><br><br> Course you would like to study: <input id="00N0Y00000RWiNi" maxlength="255" name="00N0Y00000RWiNi" size="20" type="text" /><br><br>
<label for="lead_source">Where did you hear about us?</label> <select id="lead_source" name="lead_source"><option value="">--None--</option>
<option value="Instagram">Instagram</option>
<option value="Facebook">Facebook</option>
<option value="Twitter">Twitter</option>
<option value="Google">Google</option>
<option value="School Counsellor_(Please specify)">School Counsellor_(Please specify)</option>
<option value="University Website_(Please specify)">University Website_(Please specify)</option>
<option value="Web">Web</option>
</select><br><br>
<input type=hidden id="00N0Y00000RWvPA" name="00N0Y00000RWvPA" type="checkbox" value="1" />
<center><input type="submit" name="submit"></center>
</form>
这篇关于仅HTML格式的拉丁字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!