如何确定Html.EditorFor的第一个字母是“P”,如果是,请关注下一个Html.EditorFor?例如:我有3个Html.Editor对于我想要做的事情就像我的第一个Html.EditFor必须有“P”的第一个字母,如果它有更改到下一个Html.EditorFor,并与第二个我会检查“Q”,如果有它到下一个Html.EditorFor,那样......?
答案 0 :(得分:0)
如果有人需要它,这是一种方法。
<input type="text" id="txt" onkeypress="myFunction(event)">
<input type="text" id="txt1" name="txt1">
function myFunction(e) {
if(e.keyCode === 13)
{
var value = document.getElementById("txt").value;
var txt = value.substr(0,1);
if (txt === "P") {
$(document.getElementById("txt")).css("background-color", "white");
document.getElementById("txt1").focus();
}else{
$(document.getElementById("txt")).css("background-color", "red");
$(document.getElementById("txt")).val("");
}
}