在文本字段中定义值 [英] Define a value in text field

查看:91
本文介绍了在文本字段中定义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个表格,我用的很好。



如果一个人填写他的电话号码,例如:0525558887,这是我国的正确格式,然后数据提交到我公司的CRM。



我想要实现一个代码,该代码将作用于该特定字段上的预定义perfix,例如:如果某人将使用0525558887填写表单,则提交的数据将被处理为972525558887意味着减少'0'并添加972




任何帮助或提示都是适用的。



谢谢。

Hello there,

I have a form I use and it works fine.

If a person fills in his phone number for example: 0525558887 which is the right format in my country, then ths data is submitted to my company's CRM.

I would like to implement a code that will act like pre-defined perfix on that certain field, for example: If a person will fill the form with 0525558887, the data that submitted will be processed as 972525558887 means cutting the '0' and adding 972


Any help or tip is appriciated.

Thanks.

推荐答案

请参阅我对该问题的评论。例如,您可以使用 http://stackoverflow.com/questions / 10073699 / pad-a-number-with-leading-zeros-in-javascript [ ^ ]。



或者,你可以使用一个或另一个屏蔽输入控制并记住字符串本身,而不仅仅是相应的数值。例如,参见 http://jsfiddle.net/SO_AMK/SEXAj [ ^ ]。



-SA
Please see my comment to the question. You can use, for example, http://stackoverflow.com/questions/10073699/pad-a-number-with-leading-zeros-in-javascript[^].

Alternatively, you can use one or another masked input control and remember the string itself, not just corresponding numeric value. See, for example, http://jsfiddle.net/SO_AMK/SEXAj[^].

—SA


好吧,我的手机号码是,0332 - *******,但是如果我不得不把它给你,我将不得不去除第一个零(前导零) )并将国家代码添加到其中,+ 92。因此,您可以使用我的国际电话号码与我联系。当然,我可以发送我的手机号码,是的,在我自己的国家,如果发现从零开始,则为手机号码。



对于您的场景,蒙面输入将非常合适(参见解决方案1中的链接 [ ^ ] )因为使用该机制为字符添加前缀的脚本效率不高; 相信我,我试过了。如果用户没有输入正确的输入,如果用户已经添加了零,或者如果他没有输入,或者如果他自己输入国家代码怎么办?该怎么办?



在这种情况下,我会(如果我必须编写应用程序)检查一个Combobox( select in HTML)控件(在大多数软件开发框架中),其中包含电话号码的国家/地区代码。然后,您可以询问用户自己的号码,而无需国家/地区代码。用户输入的数字为332 - *******(没有零,或国家代码或其他相同的愚蠢的基于标准的的东西)。然后,我可以附加+92并将其存储在我的数据库中或处理它。同样应该在这里完成!它让你的生活变得轻松;)



大多数巨头这样做,他们会询问您没有国家代码的号码,并提供您选择的国家/地区名称列表,他们将国家代码附加到它。
Well, my cell phone number is, 0332-*******, but if I had to give it to you I would have to strip out the first zero (leading zero) and add the country code to it, +92. Thus, you can contact me using my phone number, internationally. Of course I can send my cell number, and yes, in my own country the cell number if found to be starting with a zero.

For your scenario, a masked input would be a perfect fit (See the link[^] in Solution 1) because a script that uses the mechanism to prefix the characters is not efficient; believe me I tried it. What if the user doesn't enter the correct input, what if user already has added the zero, or what if he hasn't, or what if he enters the country code himself?

In such cases, I would (if I had to write the application) check a Combobox (select in HTML) control (In most of the software development frameworks), which holds the country codes for the phone numbers. Then, you can ask the user for his own number, without the country code. User would enter the number as, 332-******* (without the zero, or country code or other same stupid standard-based stuff). Then, I can append the +92 and store it in my database or process it. Same should be done here! It makes your life easy. ;)

Most of the giants do that, they ask you for your number without country code and give you a list of country names that you chose from and they append the country code to it.


这篇关于在文本字段中定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆