我想验证一个URL并显示消息.以下是我的代码:
$("#pageUrl").keydown(function(){
$(".status").show();
var url = $("#pageUrl").val();
if(isValidURL(url)){
$.ajax({
type: "POST",
url: "demo.php",
data: "pageUrl="+ url,
success: function(msg){
if(msg == 1 ){
$(".status").html('<img src="images/success.gif"/><span><strong>SiteID:</strong>12345678901234456</span>');
}else{
$(".status").html('<img src="images/failure.gif"/>');
}
}
});
}else{
$(".status").html('<img src="images/failure.gif"/>');
}
});
function isValidURL(url){
var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if(RegExp.test(url)){
return true;
}else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,即使输入正确的URL直到它与正则表达式匹配,它也会显示错误消息,即使URL类似,它也会返回true "http://wwww".
我感谢你的建议.
我能够让所有三个人在"Scala项目"中运行一个Hello World,并以.java文件为主.问题是它是从我没有使用的"Java项目"中提取的,尽管我的"Scala项目"中有JRE系统库.以下是我正在做的有助于理解的代码......
JRuby.java
import org.jruby.embed.ScriptingContainer;
public class JRuby {
public static void main(String[] args)
{
System.out.println("Java, Scala and Ruby using the JRE.\n");
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("puts 'This is JRuby code in .java file!'");
new ScallaHello().hello();
System.out.println("This is standard Java Code in .java file!");
}
}
Run Code Online (Sandbox Code Playgroud)
ScallaHello.scala
class ScallaHello {
def hello() {
println("This is a Scala Method in .scala file, object set in .java file")
}
System.out.println("This is Java Code in .scala file!")
println("This is Scalla …Run Code Online (Sandbox Code Playgroud) 我对Ruby有一些经验,但它不如我的Python经验.我打包并发布了几个Python包,但是我发布的只有一个Ruby包.我想通过与Python比较来快速了解Ruby包装生态系统.
setup.py develop命令 - 它解析了依赖关系,但没有安装到site-packages.Ruby中的等价物是什么?是否有一个小而美丽的程序来演示Perl OO,我可以学习和遵循; 使用bless,包括构造函数,析构函数,继承和几乎所有的OO东西?
谢谢.
comparison ×1
eclipse ×1
jar ×1
java ×1
javascript ×1
jquery ×1
jruby ×1
packaging ×1
perl ×1
python ×1
ruby ×1
rubygems ×1
scala ×1
url ×1
validation ×1