我需要在JavaScript中验证澳大利亚的电话号码(例如02[3-9]\d{7}或07[3-9]\d{7} 或04[\d]{8}).
要求:
目前我可以验证必填字段和电子邮件地址,但我想添加电话号码验证.
<html>
<head>
<script type="text/javascript">
function validateForm() {
var x=document.forms["form3"]["name"].value;
if (x==null || x=="") {
alert("Name must be filled out");
return false;
}
var s=document.forms["form3"]["phone"].value;
if (s==null || s=="") {
alert("Please Enter your Phone or Mobile Number - Preferably Phone Number");
return false;
}
var s=document.forms["form3"]["email"].value;
if (s==null || s=="") {
alert("Please Enter a valid email address");
return false;
}
var k=document.forms["form3"]["email"].value;
var atpos=k.indexOf("@");
var dotpos=k.lastIndexOf(".");
if …Run Code Online (Sandbox Code Playgroud) 嗨,这已经开始了几天了,我想重定向到移动网站,以便从屏幕宽度低于699的设备检查网站.我使用此脚本进行重定向:
<script type="text/javascript">
<!--
if (screen.width <= 699) {
window.location = "http://www.mywebsite.com.au/mobile/";
}
//-->
</script>
Run Code Online (Sandbox Code Playgroud)
当我通过Firefox检查网站但没有在Dolphin浏览器中工作时,脚本工作正常.
它可能只是我的手机,我有一个Galaxy S2.
提前感谢任何可以帮助我的人,我真的很感激!
新更新:-----确定这非常有趣.当我将屏幕宽度减小到599时,脚本在Dolpin浏览器中工作.(screen.width <= 599)---
我在我的网站的根文件夹下使用htaccess规则以删除文件扩展名并在末尾添加尾部斜杠.但是,我想从根文件夹htaccess规则中排除子目录/ sub-dir /.我试图将另一个htaccess添加到/ sub-dir /文件夹并放入RewriteOptions inherit或RewriteEngine Off放在文件中,但它们都不起作用.
RewriteEngine On
RewriteBase /
# redirect from non-www to www
RewriteCond %{HTTP_HOST} ^mywebsite.com.au$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com.au/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteRule ^(.*)index.php$ http://www.mywebsite.com.au/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
# Remove trailing slash:
RewriteRule (.*)/$ $1 [L]
# Now test without the trailing slash:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_FILENAME}.php [QSA,L]
Run Code Online (Sandbox Code Playgroud)
任何建议都非常感谢.
谢谢
javascript ×2
.htaccess ×1
apache ×1
forms ×1
mobile ×1
php ×1
redirect ×1
regex ×1
validation ×1