如何删除字符串中的最后一个字符,例如在123-4-我删除4它时应该123-使用jQuery显示.
如何使用C#删除两个单词之间的额外空格?考虑:
"Hello World"
Run Code Online (Sandbox Code Playgroud)
我希望这被操纵为"Hello World".
嗨,我正在构建一个用户必须在文本框中输入SSN的应用程序.是否可以自动插入连字符( - ),就像在3后输入123连字符一样,即123-.在以5 = 123-45-之后键入123-45连字符之后以相同的方式.最后123-45-6789.如果输入错误,我必须能够更改号码.
嗨我在没有$(document).ready的情况下放置以下代码正常工作
<asp:TextBox ID="TextBox_FirstName" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox_LastName" runat="server"></asp:TextBox>
<asp:Button ID="txtSubmit" Text="Validate" runat="server" />
<asp:CustomValidator ID="AtLeastOneTextBoxValidator" runat="server"
ClientValidationFunction="Validate_Textbox" ValidateEmptyText="true">
</asp:CustomValidator>
function Validate_Textbox(sender, args) {
var firstName = document.getElementById("<%= TextBox_FirstName.ClientID %>");
var lastName= document.getElementById("<%= TextBox_LastName.ClientID%>");
if ((firstName == "") && (lastName == "")){
window.alert("Error");
}
}
Run Code Online (Sandbox Code Playgroud)
当我将此代码放在$(document).ready中时,它会给出' Microsoft JScript运行时错误:对象预期'错误.
$(document).ready( function(){
function Validate_Textbox(sender, args) {
var firstName = document.getElementById("<%= TextBox_FirstName.ClientID %>");
var lastName = document.getElementById("<%= TextBox_LastName.ClientID%>");
if ((firstName == "") && (lastName == "")){
window.alert("Error");
}
}
});
Run Code Online (Sandbox Code Playgroud)