本文介绍了用于文本框的Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Hii朋友, 我希望javascript用于验证文本框值的文本框。 文本框值应以http:\\\开头\\或https:\\ 我不太了解javascript .. plzz帮助我。Hii friends,I want javascript for textbox that validate textbox value.Textbox value should start with http:\\ or https:\\I dont know javascript much..plzz help me.推荐答案<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script src="jquery.js.js"></script> <script type="text/javascript"> var validate = function (control) { var value = control.value; if (value.substring(0, 7) == "http:\\\\" || value.substring(0, 8) == "https:\\\\") return true; else { alert('invalid url'); return false; } } </script></head><body> <form id="form1" runat="server"> <asp:TextBox ID="txtUrl" runat="server"></asp:TextBox> <br /> <asp:Button ID="btn" runat="server" Text="submit" OnClientClick="return validate(txtUrl);" /> </form></body></html><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" EnableViewState="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script type="text/javascript"> if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (prefix) { return this.slice(0, prefix.length) == prefix; }; } function ValidateUrl() { var url = 这篇关于用于文本框的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 15:20
查看更多