私はCRMフォームのphoneNumber.lengthをチェックしています。これまでのところ、私は8-15文字の間でチェックを受けました=動作するように受け入れてください。私はスタックしようとすると、ゼロ文字をチェックするには「が」私が取得: 例外TypeError:私が手にしたら、私は上の作業を開始します整理そのcheckPhoneNumberJavaScriptヌルのプロパティ 'preventDefault'を読み取ることができません
function checkPhoneNumber(executioncontext) {
var phoneNumber;
phoneNumber = Xrm.Page.getAttribute("telephone1").getValue();
if (phoneNumber == null) {
Xrm.Page.ui.setFormNotification("Phonenumber can't be empty", "WARNING", "telephone1nc1");
Xrm.Page.getControl("telephone1").setFocus(true);
executioncontext.getEventArgs().preventDefault();
} else {
Xrm.Page.ui.clearFormNotification("telephone1nc1");
//Insert 8-15 characters
if (phoneNumber != null) {
if (phoneNumber.length < 8 || phoneNumber.length > 15) {
Xrm.Page.ui.setFormNotification("Phonenumber must be between 8-15 chars..", "ERROR", "telephoneerror1");
Xrm.Page.getControl("telephone1").setFocus(true);
} else {
if (phoneNumber == null) {
Xrm.Page.ui.setFormNotification("Telefonnummret får inte vara tomt", "WARNING", "telephone1nc1");
Xrm.Page.getControl("telephone1").setFocus(true);
//executioncontext.getEventArgs().preventDefault(); //vid 0 bombar scriptet
} else {
Xrm.Page.ui.clearFormNotification("telephone1nc1");
}
Xrm.Page.ui.clearFormNotification("telephoneerror1");
}
/*var regex = /^\+(?:[0-9] ?){6,14}[0-9]$/;
if (regex.test(executionObj)) {
// Valid international phone number
} else {
// Invalid international phone number */
}
}
}
でヌルのプロパティ「でpreventDefault」を読み取ることができません国際フォーマットをチェックし、エンティティの国に基づいて国コードを挿入するコード。したがって、コメントvar正規表現。 Dynamics CRMのための
'executioncontext.getEventArgs()'あなたのエラーの原因となる、nullを返します。 その理由は、 'executioncontext'変数にもっと多くのコンテキストが必要です。 – Antony
ああ、そうです。 'Xrm.Page.ui.setFormNotification("警告 "、" telephone1nc1 ");' 一度電話機1に値が入力されると、警告メッセージ「Xrm.Page.ui.setFormNotification」をクリアします。 – Paladin