更新时间:2023-02-05 19:47:41
( document )。ready( function (){
( #btnRegister)。click( function (){
if (
( #txtFirstname)。val()== 0 ||
I've got problem: this script gets executed twice.
/// <reference path="jquery-1.8.2.min.js" />
$(document).ready(function () {
$("#btnRegister").click(function () {
if ($("#txtFirstname").val() == 0 || $("#txtNickname").val() == 0 || $("#txtGmail").val() == 0 || $("#txtPassword").val() == 0 || $("#txtBirth").val() == 0) {
alert("Data Empty");
}
else {
Register();
}
});
function Register() {
var IsMale = 1;
var name = $("#txtFirstname").val();
var nickName = $("#txtNickname").val();
var email = $("#txtGmail").val();
var password = $("#txtPassword").val();
var birthDate = $("#txtBirth").val();
alert(name);
alert(nickName);
alert(email);
alert(password);
alert(birthDate);
alert(name);
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "http://localhost:3148/api/values/5",
success: function (data) {
alert("Success 2");
alert(data);
var obj = jQuery.parseJSON(data);
alert("ID =" + obj.longPachage.Id);
window.location.href = "index.html";
},
error: function (data) {
alert(" Error ");
}
})
}
});
What I have tried:
i tried to execute without the button but still executed twice
(document).ready(function () {
("#btnRegister").click(function () { if (
("#txtFirstname").val() == 0 ||