我有一个文本框,我用它来输入 URL。我希望当我单击提交按钮时,文本框已验证。
我希望在文本框中输入的值是包含 http://www.
部分的有效 URL
我基本上希望它是一个有效的 URL。 表单的代码是
<form action="next.php" method="get">
<input id="home_page_input" type="text" name="page" value="http://"onfocus="this.value = ( this.value == this.defaultValue ) ? '' : this.value;return true;">
<input id="url_input_button" type="submit" value="enter it !" />
</form>
实际上,此表单正在发送到使用 Curl/file_get_contents 的 php 文件。所以我只想采用一种curl不会显示任何错误的格式
最佳答案
jQuery 验证插件支持 URL 验证。请参阅 http://docs.jquery.com/Plugins/validation 中的示例
关于javascript - 通过 JavaScript 进行验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5067410/