我正在开发一个Web应用程序。在那,我使用Javascript文件进行验证。 它工作正常,但现在我在javascript文件中做了一些更改。 我只收到旧的提醒信息。 但是在那个Javascript文件中,我没有警报消息。 这是我的旧js和新js。
新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;
}
答案 0 :(得分:0)
Javascript文件像其他文件一样缓存,因此可能有您的浏览器缓存,代理缓存等。更改JS文件的名称可能是最简单的解决方案,让每个人都更新它。如果在您的Web应用程序中引用了文件myjslibrary.js,请参阅myjslibrary2.js并重命名该文件。
但可能只是本地缓存问题(您的浏览器),只是尝试强制清除浏览器缓存:http://www.refreshyourcache.com/en/cache/