Javascript 客户端验证在Internet Explorer 9中不起作用
我刚刚创建了MVC4应用程序。在该应用程序中,我有一个表单要插入部门。对于该表单,我使用客户端验证 这些客户端验证可以在Firefox和Chrome中正常工作,但不能在IE9(Internet Explorer)中正常工作 这是我的模型课Javascript 客户端验证在Internet Explorer 9中不起作用,javascript,c#,asp.net-mvc,internet-explorer-9,client-side-validation,Javascript,C#,Asp.net Mvc,Internet Explorer 9,Client Side Validation,我刚刚创建了MVC4应用程序。在该应用程序中,我有一个表单要插入部门。对于该表单,我使用客户端验证 这些客户端验证可以在Firefox和Chrome中正常工作,但不能在IE9(Internet Explorer)中正常工作 这是我的模型课 public partial class tbl_hec_Department { public tbl_hec_Department() { this.tbl_hec_level_of_Stu
public partial class tbl_hec_Department
{
public tbl_hec_Department()
{
this.tbl_hec_level_of_Study = new HashSet<tbl_hec_level_of_Study>();
this.tbl_hec_Programme = new HashSet<tbl_hec_Programme>();
}
[Required]
[DisplayName("Department ID")]
[Remote("doesDepartment_IDExist", "HEC", HttpMethod = "POST", ErrorMessage = "Department ID already exists.")]
public string Department_ID { get; set; }
[Required]
[DisplayName("Name of Department")]
public string Name_of_Department { get; set; }
[DataType(DataType.PhoneNumber)]
[DisplayName("Telephone Number")]
//[StringLength(50, ErrorMessage = "Please enter a minimum of {2} characters", MinimumLength = 6)]
public string Contact_General_Line { get; set; }
//[StringLength(50, ErrorMessage = "Please enter a minimum of {2} characters", MinimumLength = 6)]
[DisplayName("Fax Number")]
public string Contact_Fax_Number { get; set; }
[Required]
[EmailAddress(ErrorMessage = "Please enter a valid email address")]
[DisplayName("Email Address")]
public string Contact_Email { get; set; }
[Required(ErrorMessage = "Please select the {0}")]
[DisplayName("University / Institute")]
public string HEI_ID { get; set; }
[Required(ErrorMessage = "Please select the {0}")]
[DisplayName("College")]
public string College_ID { get; set; }
[DisplayName("Status")]
public Nullable<bool> Status { get; set; }
public string Create_By { get; set; }
public Nullable<System.DateTime> Create_Date { get; set; }
public string Update_By { get; set; }
public Nullable<System.DateTime> Update_Date { get; set; }
public virtual tbl_hec_College tbl_hec_College { get; set; }
public virtual tbl_hec_University tbl_hec_University { get; set; }
public virtual ICollection<tbl_hec_level_of_Study> tbl_hec_level_of_Study { get; set; }
public virtual ICollection<tbl_hec_Programme> tbl_hec_Programme { get; set; }
}
我很确定客户端机器浏览器中的java脚本已被禁用。首先,检查在客户端浏览器中是否启用或禁用java脚本。您可以使用此代码通过编程进行检查
public static bool IsJavascriptEnabled( )
{
bool retVal = true;
//get the registry key for Zone 3(Internet Zone)
Microsoft.Win32.RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", true);
if (key != null)
{
Object value = key.GetValue(DWORD_FOR_ACTIVE_SCRIPTING, VALUE_FOR_ENABLED);
if( value.ToString().Equals(VALUE_FOR_DISABLED) )
{
retVal = false;
}
}
return retVal;
}
您也可以访问此链接客户端脚本在哪里?@colecm-可能使用不引人注目的验证。如果JS是问题所在,那么我从布局文件中获取的JS?脚本在哪里?但很少有验证工作如图所示。怎么会这样
public static bool IsJavascriptEnabled( )
{
bool retVal = true;
//get the registry key for Zone 3(Internet Zone)
Microsoft.Win32.RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", true);
if (key != null)
{
Object value = key.GetValue(DWORD_FOR_ACTIVE_SCRIPTING, VALUE_FOR_ENABLED);
if( value.ToString().Equals(VALUE_FOR_DISABLED) )
{
retVal = false;
}
}
return retVal;
}