我正在開發一個Web應用程序。在那裏,我使用了一個Javascript文件進行驗證。 它工作正常,但現在我在JavaScript文件中做了一些更改。 我只收到舊的警報消息。 但是在那個Javascript文件中,我沒有警告消息。 這是我的老js和新的js。JavaScript文件未在ASP.net網站中更新
新的JavaScript:
function ValidateSkill() {
var skill1 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet1');
var skillrate1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlselfrating');
var skill2 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet2');
var skillrate2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating1');
var skill3 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet3');
var skillrate3 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating2');
var skill4 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet4');
var skillrate4 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating3');
var skill5 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet5');
var skillrate5 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating4');
var skill6 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet6');
var skillrate6 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating5');
var count = 0;
if (skill1.value != "") {
count++;
if (skillrate1.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate1.focus();
return false;
}
}
if (skill2.value != "") {
count++;
if (skillrate2.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate2.focus();
return false;
}
}
if (skill3.value != "") {
count++;
if (skillrate3.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate3.focus();
return false;
}
}
if (skill4.value != "") {
count++;
if (skillrate4.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate4.focus();
return false;
}
}
if (skill5.value != "") {
count++;
if (skillrate5.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate5.focus();
return false;
}
}
if (skill6.value != "") {
count++;
if (skillrate6.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate6.focus();
return false;
}
}
if (count == 0) {
alert('Please enter atleast one Skill Set');
skill1.focus();
return false;
}
return ValidateUnqiue();
}
function ValidateUnqiue() {
var skill1 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet1');
var skill2 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet2');
var skill3 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet3');
var skill4 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet4');
var skill5 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet5');
var skill6 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet6');
var count = 0;
if (skill1.value != "") {
count++;
}
if (skill2.value != "") {
count++;
}
if (skill3.value != "") {
count++;
}
if (skill4.value != "") {
count++;
}
if (skill5.value != "") {
count++;
}
if (skill6.value != "") {
count++;
}
if (count == 0) {
alert('enter altleast one skill set');
return false;
}
var skillarr = new Array();
skillarr[skillarr.length] = skill1.value;
skillarr[skillarr.length] = skill2.value;
skillarr[skillarr.length] = skill3.value;
skillarr[skillarr.length] = skill4.value;
skillarr[skillarr.length] = skill5.value;
skillarr[skillarr.length] = skill6.value;
for (var i = 0; i < skillarr.length; i++) {
for (var j = i + 1; j < skillarr.length; j++) {
if (skillarr[i] != "" && skillarr[j] != "") {
if (skillarr[i] == skillarr[j]) {
alert("Don't enter the same skill");
return false;
}
}
}
}
return true;
}
舊的JavaScript
function Validate() {
var skill1 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet1');
var skillrate1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlselfrating');
var skill2 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet2');
var skillrate2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating1');
var skill3 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet3');
var skillrate3 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating2');
var skill4 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet4');
var skillrate4 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating3');
var skill5 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet5');
var skillrate5 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating4');
var skill6 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet6');
var skillrate6 = document.getElementById('ctl00_ContentPlaceHolder1_ddlSelfrating5');
var count = 0;
if (skill1.value != "") {
count++;
if (skillrate1.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate1.focus();
return false;
}
}
if (skill2.value != "") {
count++;
if (skillrate2.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate2.focus();
return false;
}
}
if (skill3.value != "") {
count++;
if (skillrate3.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate3.focus();
return false;
}
}
if (skill4.value != "") {
count++;
if (skillrate4.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate4.focus();
return false;
}
}
if (skill5.value != "") {
count++;
if (skillrate5.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate5.focus();
return false;
}
}
if (skill6.value != "") {
count++;
if (skillrate6.selectedIndex == 0) {
alert('Please enter the Self rating');
skillrate6.focus();
return false;
}
}
if (count == 0) {
alert('Please enter atleast one Skill Set');
skill1.focus();
return false;
}
return ValidateUnqiue();
}
function ValidateUnqiue() {
var skill1 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet1');
var skill2 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet2');
var skill3 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet3');
var skill4 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet4');
var skill5 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet5');
var skill6 = document.getElementById('ctl00_ContentPlaceHolder1_txtbxSkillSet6');
if (skill1.value == skill2.value || skill1.value == skill3.value || skill1.value == skill4.value || skill1.value == skill5.value || skill1.value == skill6.value) {
alert('Do not enter the same skill set more than once');
return false;
}
if (skill2.value == skill1.value || skill2.value == skill3.value || skill2.value == skill4.value || skill2.value == skill5.value || skill2.value == skill6.value) {
alert('Do not enter the same skill set more than once');
return false;
}
if (skill3.value == skill1.value || skill3.value == skill2.value || skill3.value == skill4.value || skill3.value == skill5.value || skill3.value == skill6.value) {
alert('Do not enter the same skill set more than once');
return false;
}
if (skill4.value == skill1.value || skill4.value == skill3.value || skill4.value == skill2.value || skill4.value == skill5.value || skill4.value == skill6.value) {
alert('Do not enter the same skill set more than once');
return false;
}
if (skill5.value == skill1.value || skill5.value == skill3.value || skill5.value == skill4.value || skill5.value == skill2.value || skill5.value == skill6.value) {
alert('Do not enter the same skill set more than once');
return false;
}
if (skill6.value == skill1.value || skill6.value == skill3.value || skill6.value == skill4.value || skill6.value == skill5.value || skill6.value == skill2.value) {
alert('Do not enter the same skill set more than once');
return false;
}
return true;
}
你構建解決方案和網站? – MusicLovingIndianGirl
是的,我構建解決方案 –
發佈您的代碼。 – MusicLovingIndianGirl