×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

当我按 ADD 这个BUTTON时,为什么说我Error: Type mismatch :validate.难道这个函数参数写的不对?

本文发表在 rolia.net 枫下论坛<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<link rel="stylesheet" type="text/css" href="http://rnd/rnd/css/style1.css">
<script language="vbscript">
function validate(int b)
a=trim(document.form1.RCvalue.value)
if a="" or (not isnumeric(a)) then
alert("Please enter a value.")
document.form1.RCvalue.focus()
elseif a<0.1 and b=0 then
alert("Value should greater than 0.1")
document.form1.RCvalue.focus()
elseif a>=1000 and b=0 then
alert("Value should less than 1000")
document.form1.RCvalue.focus()
else
if b=1 then
a=trim(document.form1.voltage.value )
if a="" or not isnumeric(a) then
alert("Please enter a voltage.")
document.form1.voltage.focus()
elseif
document.form1.submit()
end if
else
document.form1.submit()
end if
end if
end function
</script>
</HEAD>

<body onload="javascript:{if(parent.frames[0]&amp;&amp;parent.frames['Top'].Go)parent.frames['Top'].Go();document.form1.RCvalue.focus()}">

<center>
<form action="smadd2.asp?no1=311&type=R1" method="post" name=form1 id=form1>
<H3>
Step 2: New type for 311(SMD Single Resistors)</h3>

<table width=60% border=1>
<tr><th>Value(Ohm)</th><td><input id=RCvalue name=RCvalue size=4 maxlength=4>
<select id=unit name=unit>
<option value=1>&nbsp;</option>
<option value=2>K</option>
<option value=3>M</option>
</select>Ohms</td></tr>
<tr><th>Accurency(%)</th>
<td><input type=radio checked id=accur name=accur value=1>1%
<input type=radio id=accur name=accur value=2>2%
<input type=radio id=accur name=accur value=5>5%
<input type=radio id=accur name=accur value=10>10%
</td></tr>

<tr><th>Package</th><td>
<select id=pack name=pack>

<option value="03Resistor 0402">Resistor 0402 </option>

<option value="01Resistor 0603">Resistor 0603 </option>

<option value="02Resistor 0805">Resistor 0805 </option>

</select></td></tr>

</table>
<br>
<input type=button value=" Add " onclick="validate(0)" id=button2 name=button2>

</form>
</center>
</BODY>
</HTML>更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 当我按 ADD 这个BUTTON时,为什么说我Error: Type mismatch :validate.难道这个函数参数写的不对?
    本文发表在 rolia.net 枫下论坛<HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <link rel="stylesheet" type="text/css" href="http://rnd/rnd/css/style1.css">
    <script language="vbscript">
    function validate(int b)
    a=trim(document.form1.RCvalue.value)
    if a="" or (not isnumeric(a)) then
    alert("Please enter a value.")
    document.form1.RCvalue.focus()
    elseif a<0.1 and b=0 then
    alert("Value should greater than 0.1")
    document.form1.RCvalue.focus()
    elseif a>=1000 and b=0 then
    alert("Value should less than 1000")
    document.form1.RCvalue.focus()
    else
    if b=1 then
    a=trim(document.form1.voltage.value )
    if a="" or not isnumeric(a) then
    alert("Please enter a voltage.")
    document.form1.voltage.focus()
    elseif
    document.form1.submit()
    end if
    else
    document.form1.submit()
    end if
    end if
    end function
    </script>
    </HEAD>

    <body onload="javascript:{if(parent.frames[0]&amp;&amp;parent.frames['Top'].Go)parent.frames['Top'].Go();document.form1.RCvalue.focus()}">

    <center>
    <form action="smadd2.asp?no1=311&type=R1" method="post" name=form1 id=form1>
    <H3>
    Step 2: New type for 311(SMD Single Resistors)</h3>

    <table width=60% border=1>
    <tr><th>Value(Ohm)</th><td><input id=RCvalue name=RCvalue size=4 maxlength=4>
    <select id=unit name=unit>
    <option value=1>&nbsp;</option>
    <option value=2>K</option>
    <option value=3>M</option>
    </select>Ohms</td></tr>
    <tr><th>Accurency(%)</th>
    <td><input type=radio checked id=accur name=accur value=1>1%
    <input type=radio id=accur name=accur value=2>2%
    <input type=radio id=accur name=accur value=5>5%
    <input type=radio id=accur name=accur value=10>10%
    </td></tr>

    <tr><th>Package</th><td>
    <select id=pack name=pack>

    <option value="03Resistor 0402">Resistor 0402 </option>

    <option value="01Resistor 0603">Resistor 0603 </option>

    <option value="02Resistor 0805">Resistor 0805 </option>

    </select></td></tr>

    </table>
    <br>
    <input type=button value=" Add " onclick="validate(0)" id=button2 name=button2>

    </form>
    </center>
    </BODY>
    </HTML>更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • document.form1.RCvalue.value may be considered as number by the system if your input is number, you have to convert to string for string operation like trim I guess.
    • a combination of java script and vb script ? for these script , no data type define for variables. and vbscript do not have alert, use msgbox. also, one of the elseif should be else. try this
      本文发表在 rolia.net 枫下论坛<HTML>
      <HEAD>
      <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
      <link rel="stylesheet" type="text/css" href="http://rnd/rnd/css/style1.css">
      <script language="vbscript">
      function validate(b)
      a=trim(document.form1.RCvalue.value)
      if a="" or (not isnumeric(a)) then
      msgbox("Please enter a value.")
      document.form1.RCvalue.focus()
      elseif a<0.1 and b=0 then
      msgbox("Value should greater than 0.1")
      document.form1.RCvalue.focus()
      elseif a>=1000 and b=0 then
      msgbox("Value should less than 1000")
      document.form1.RCvalue.focus()
      else
      if b=1 then
      a=trim(document.form1.voltage.value )
      if a="" or not isnumeric(a) then
      msgbox("Please enter a voltage.")
      document.form1.voltage.focus()
      else
      document.form1.submit()
      end if
      else
      document.form1.submit()
      end if
      end if
      end function
      </script>
      </HEAD>

      <body onload="javascript:{if(parent.frames[0]&amp;&amp;parent.frames['Top'].Go)parent.frames['Top'].Go();document.form1.RCvalue.focus()}">

      <center>
      <form action="smadd2.asp?no1=311&type=R1" method="post" name=form1 id=form1>
      <H3>
      Step 2: New type for 311(SMD Single Resistors)</h3>

      <table width=60% border=1>
      <tr><th>Value(Ohm)</th><td><input id=RCvalue name=RCvalue size=4 maxlength=4>
      <select id=unit name=unit>
      <option value=1>&nbsp;</option>
      <option value=2>K</option>
      <option value=3>M</option>
      </select>Ohms</td></tr>
      <tr><th>Accurency(%)</th>
      <td><input type=radio checked id=accur name=accur value=1>1%
      <input type=radio id=accur name=accur value=2>2%
      <input type=radio id=accur name=accur value=5>5%
      <input type=radio id=accur name=accur value=10>10%
      </td></tr>
      <tr><th>Package</th><td>
      <select id=pack name=pack>

      <option value="03Resistor 0402">Resistor 0402 </option>

      <option value="01Resistor 0603">Resistor 0603 </option>

      <option value="02Resistor 0805">Resistor 0805 </option>

      </select></td></tr>

      </table>
      <br>
      <input type=button value=" Add " onclick="validate(0)" id=button2 name=button2>

      </form>
      </center>
      </BODY>
      </HTML>更多精彩文章及讨论,请光临枫下论坛 rolia.net