電話番号の文字数制限

Highlighted
Anonymous
Not applicable

電話番号の文字数制限

フォームの電話番号フィールドが入力必須なのに3ケタ入力しただけで

送信できてしまいます。

設定はフォームのフィールドの詳細で行うものですか?

11 REPLIES 11
Highlighted
Level 10 - Champion Alumni

Re: 電話番号の文字数制限

If you need 3 digits in the field, you can use field masking in the Form Setup, but it won't force it. You need javascript to enforce rules for this. Find a web developer.

Highlighted
Anonymous
Not applicable

Re: 電話番号の文字数制限

HI Josh

Thank you for your help.

Other expert answered this question,but it didn't enough.

I don't need to have 3 digits, 

The probrem is that the phone field would be sent with the phone number which is incorrect,

even if the field is input required.

I found the code below and need to change the green colored part to put it in our embed code.

Would you help me?

form.vals({ "Phone":"555-555-1234", "Country":"USA"});

1. The minimum number is 10 and no hyphen. How do you code?

2. "Phone"  should be same as the field name of the form, right?

3. Is "Country" necessary? If so,what it would be like?  For example,"japan" didn't work. "ja" ? "JAPAN" ?

Highlighted
Anonymous
Not applicable

Re: 電話番号の文字数制限

See Forms 2.0 » Marketo Developers​ example 3 and 7

I think your code

form.vals({ "Phone":"555-555-1234", "Country":"USA"});

is not validation code.

i think Example 9 is your solution.

Highlighted
Anonymous
Not applicable

Re: 電話番号の文字数制限

Hi Takahashi San

日本人の方でいらっしゃいますか?

お答えありがとうございます。

Highlighted

Re: 電話番号の文字数制限

風間さん、

この例ではあなたが望むものではありません。あれはデータを事前入力するフォームのAPIを使用しています。この問題を解決するためにJavaScriptを使用しています。電話番号10文字の入力をしたい場合は、使用:

<script type="text/javascript">

document.addEventListener('DOMContentLoaded', function() {

document.getElementById("phone")[0].setAttribute("pattern", ".{10,}");

});

</script>

ちょっと日本語を話せでも〜5年で話されていません。済みません。

ーグライムズ

Highlighted
Level 10 - Community Moderator

Re: 電話番号の文字数制限

Hey Courtney,

This should in the form's onReady, not in the body onload, otherwise you have a race condition (the form elements can't be expected to exist onload).

Highlighted

Re: 電話番号の文字数制限

そうですねーupdated accordingly.

Highlighted
Level 10 - Community Moderator

Re: 電話番号の文字数制限

Unless there's something I'm missing in the Japanese it still has to be in MktoForms2.whenReady.

DOMContentLoaded is guaranteed to miss the element.

Or is this not a Marketo form?

Highlighted

Re: 電話番号の文字数制限

Is there a way to call the form once it's fully loaded without specifying the actual form via the Forms 2.0 JS API, though? I'm trying to come up with a neutral solution, and usually when deploying something neutral I've got something to go with in terms of an action beyond page fully loaded, a la:

var parentForm = document.querySelector("[id^=mktoForm_]");

parentForm.addEventListener("action", someFunction, false);