2016-05-03 13 views
0

JavaScriptの有効化&アラートはInternet Explorerでは動作していますが、Chromeでは動作していません。 Plsは問題の理解に役立ち、同じ問題に対する解決策を提供します。 Noneが渡されているようChromeでJavascriptの検証が機能しない

this.form1.i2.focus(); 
 
this.form1.i2.select(); 
 

 
function validateInput() { 
 
    userInput = new String(); 
 
    userInput = this.form1.i2.value; 
 

 
    if (userInput.match("Indica")) 
 
    document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
 
    else if (userInput.match("Innova")) 
 
    document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
 
    else if (userInput.match("Others")) 
 
    document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
 
    else if (userInput.match("Tavera")) 
 
    document.getElementById('boldStuff').innerHTML = ''; 
 
    else if (userInput.match("Tempo")) 
 
    document.getElementById('boldStuff').innerHTML = ''; 
 
}
<select name='i2' onChange='validateInput(this.value)' onClick="check2()"> 
 
    <option value='Select'>Select</option> 
 
    <option value='Tavera'>Tavera</option> 
 
    <option value='Innova'>Innova</option> 
 
    <option value='Indica'>Indica</option> 
 
    <option value='Indigo'>Indigo</option> 
 
    <option value='Tempo'>Tempo</option> 
 
    <option value='Etios'>Etios</option> 
 
    <option value='Others'>Others</option> 
 
</select> 
 
<br>

+1

こんにちは! Chrome Dev Toolsのコンソールでエラーをチェックしましたか? –

+0

このwindow.alert = nullを試してください。 alert( 'test'); // fail window.alertを削除します。 // true alert( 'test'); //勝利 –

+0

form1はどこから来たのですか? –

答えて

0

変更するには、ドロップダウンの変化にValidateInputを呼び出している機能validateInput

 

    function validateInput() { 
     userInput = new String(); 
     userInput = document.getElementById("i2").value; 

     if (userInput.match("Indica")) 
     document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
     else if (userInput.match("Innova")) 
     document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
     else if (userInput.match("Others")) 
     document.getElementById('boldStuff').innerHTML = '(Note: This vehicle to be requested one hour before)'; 
     else if (userInput.match("Tavera")) 
     document.getElementById('boldStuff').innerHTML = ''; 
     else if (userInput.match("Tempo")) 
     document.getElementById('boldStuff').innerHTML = ''; 
    } 

Alsaoの2行目、任意の引数を渡すことはありません。関数宣言で

関連する問題