I have jQuery in different files, and recently I needed to change the elements on the main page. This has led various jaavscript to include termination. Stackoverflow offers great ideas to solve the get by ID selector problem.
$("#ctl00_ContentMainPane_eliteUser").html
However, I have a problem when we used jquery.validate.js to validate form controls, so there is such code in external JS files
$(document).ready(function(){
$("#aspnetForm").validate({
rules:
{
ctl00$ContentMainPane$txtFirstName:
{
required:true,
CheckAlfaNumeric:true
},
ctl00$ContentMainPane$ctl00$ucRFI$txtComments:
{
required:true
}
},
messages:
{
ctl00$ContentMainPane$txtFirstName:
{
required:" Please enter first name"
},
ctl00$ContentMainPane$ctl00$ucRFI$txtComments:
{
required:" Please enter comments."
}
}
});
$("#" + GetPlaceholder() + "txtFirstName").blur(function(){
$("#" + GetPlaceholder() + "txtFirstName").valid();
});
jQuery.validator.addMethod("CheckAlfaNumeric", function(value, element) {
return this.optional(element) || /^[A-Za-z\ ]+$/i.test(value);
}, " Please enter alphabet.");
});
Any idea how to prevent the problem with attribute names when changing the name due to a change in the main page?
source
share