0
我有一個jQuery,它創建一個提示框,以*的形式獲取密碼。這我的代碼:在Telerik按鈕中調用jQuery代碼
$(function() {
password = $("#password"),
allFields = $([]).add(password),
tips = $(".validateTips");
function updateTips(t) {
tips
.text(t)
.addClass("ui-state-highlight");
setTimeout(function() {
tips.removeClass("ui-state-highlight", 1500);
}, 500);
}
function checkLength(o, n, min, max) {
if (o.val().length > max || o.val().length < min) {
o.addClass("ui-state-error");
updateTips("Length of " + n + " must be between " + min + " and " + max + ".");
return false;
} else {
return true;
}
}
function checkRegexp(o, regexp, n) {
if (!(regexp.test(o.val()))) {
o.addClass("ui-state-error");
updateTips(n);
return false;
} else {
return true;
}
}
$("#dialog-form").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Enter": function() {
var bValid = true;
allFields.removeClass("ui-state-error");
bValid = bValid && checkLength(password, "password", 5, 16);
// From jquery.validate.js (by joern), contributed by Scott Gonzalez:
// http://projects.scottsplayground.com/email_address_validation/
bValid = bValid && checkRegexp(password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9");
if (password.val() != "1234") {
return false;
}
if (password.val() == "1234") {
window.location.href = './Frm_Device.aspx';
alert("1234 ast");
if (bValid) {
$("#users tbody").append("<tr>" +
"<td>" + name.val() + "</td>" +
"<td>" + email.val() + "</td>" +
"<td>" + password.val() + "</td>" + "</tr>");
$(this).dialog("close");
return true;
}
}
},
Exit: function() {
$(this).dialog("close");
}
},
close: function() {
allFields.val("").removeClass("ui-state-error");
}
});
$("#create").button().click(function() {
$("#dialog-form").dialog("open");
return false;
});
});
而且我有一個Telerik按鈕。我想知道如何在這個按鈕中調用jQuery。
<telerik:RadButton ID="create" runat="server" Text="RadButton"
AutoPostBack="False" ToolTip="combined data recovered from the Teams"
class="create" OnClientClicked="?">
</telerik:RadButton>
在上面的代碼中,我應該放什麼?
請修正你的代碼的縮進,使之可讀。 – jfriend00