我需要在javascript中验证电话号码.要求是:
它们应该是10位数字,没有逗号,没有短划线,只有数字,而不是前面的1+
这是我到目前为止所写的
function validatePhone(field,alerttxt) {
with (field) {
if(value.length > 10) {
alert(alerttext);
return false;
}
for(i = 0; i < value.length; i++) {
if(parseInt(value[i]) == NaN) {
alert(alerttxt);
return false;
}
}
return true;
}
}
function validateForm(thisform) {
if (validatePhone(phone,"Invalid phone number")==false) {
phone.focus();
return false;
}
}
}
<form action="post.php" method="post" id="contactform" onsubmit="return validateForm(this)">
<ol>
<label for="phone">Your phone <span class="red"></span></label>
<input id="phone" name="phone" class="text" />
</li>
</ol>
</form>
Run Code Online (Sandbox Code Playgroud)
但是,显然它不起作用.如何编写validatePhone()函数以使其有效?
我们举个例子:
using (var someObject = new SomeObject())
{
var someOtherObject = new SomeOtherObject();
someOtherObject.someMethod();
}
Run Code Online (Sandbox Code Playgroud)
SomeOtherObject还实现了IDisposable.当SomeObject被处置时,SomeOtherObject也会被处理掉吗?SomeOtherObject会发生什么?(在SomeObject的Dispose方法中没有实现处理SomeOtherObject)
我试图找出一种使用System.Data.SQLite将CSV文件加载到SQLite DB中的一种方法
我看到命令行的方式来做到这一点,即 .Import mydata.csv mytable
但我需要通过C#代码来做到这一点.任何的想法?
我有一个PHP脚本,它从站点检索URL列表并将它们存储在MYSQL表中.我想一次又一次地运行脚本[有一段时间延迟]并更新表格.我正在使用codeigniter框架.
我该怎么做?
PS我的虚拟主机是GoDaddy
我目前正在尝试在drupal中实现第二个(较低的)管理层.我已经通过同名模块为这些用户创建了一个额外的部分,因此他们可以拥有自己的主题等.我想给这些第二或更低的管理员一个菜单在他们可以访问某些管理功能的页面部分管理其他用户和某些类型的内容等.我遇到的最大问题是安全性不一致,例如第二个管理员可以使自己成为一个完整的管理员,因为我使用drupals自己的核心管理员功能,而无法弄清楚如何永久阻止某些功能但允许其他人.在这种情况下,我想让第二个管理员能够创建和更改低级别用户的角色,而不是他自己,但无法更改或创建真正的管理员.这只是问题的一部分,但是,较小的问题是我无法为第二个管理部分保留我的主题集,而不必复制现有的管理员视图(如用户和内容的那些)并将重复项设置为我的部分下的路径.有什么建议?
我有一个.csv文件,我将在我的代码中使用oledb方法读取我现在想要这个.csv文件作为我的资源文件,所以我在资源中添加了该文件.但是从代码访问资源文件的结构,任何人都可以请帮助我
谢谢
我刚读了Factory Method.据我所知,它提供了一种将实例化委托给子类的方法.但我无法理解现实场景中的可能用途.
任何人都可以给出一个典型的例子,展示如何使用Factory方法模式,以便我可以与我所读到的内容相关联.
工厂方法模式是最佳解决方案的问题陈述足以使其清楚.
我想获取所有表列的表元数据。像 string(varchar2)/int/float/datetime 类型和字符串长度等。
干杯! -马蒂
我使用autoconf检测boost库,在autoconf-archive宏的支持下,它们可以与系统范围的boost库一起使用,但是如果我在我的主目录中手动编译boost,则会失败:
sb@stephane:~/devel/spectra2$ ./configure --with-boost=/home/sb/local/
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... …Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×2
admin ×1
ado.net ×1
autoconf ×1
boost ×1
c++ ×1
codeigniter ×1
drupal ×1
function ×1
java ×1
javascript ×1
oracle10g ×1
php ×1
sqlite ×1
user-roles ×1
using ×1
validation ×1