ASP Forum
Trying to style my submit button for captcha
bbcompent1 | Posted 1:02pm 6. May 2009 Server Time |

Ok, I'm trying to get a button to function the same as a input type submit.  I'd like to get the button to display an image instead of a grey button.  The function is there however the background image doesn't display.  The next message is the code.
bbcompent1 | Posted 1:03pm 6. May 2009 Server Time |

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>CAPTCHA Example</title>
<style type="text/css">
.buttonStyle {
background-image:url(images/btn_submit1.gif);
height:18px;
width:35px;
border:none;
}

body {
font-size:12px;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
</style>
<script language="javascript">
function RefreshImage(valImageId) {
var objImage = document.images[valImageId];
if (objImage == undefined) {
return;
}
var now = new Date();
objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <table width="400" border="1" align="center">
    <tr>
      <td colspan="2" align="center"><strong>CAPTCHA Example</strong></td>
    </tr>
    <tr>
      <td width="261">CAPTCHA Image</td>
      <td width="123"><img id="imgCaptcha" src="captcha.asp" /><br /><a href="javascript:void(0)" onclick="RefreshImage('imgCaptcha')">Change Image</a></td>
    </tr>
    <tr>
      <td>Write the characters in the image above</td>
      <td><input name="captchacode" type="text" id="captchacode" size="10" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="center" height="30px" valign="bottom"><button type="submit" class="buttonStyle" name="btnTest" id="btnTest" /></td>
    </tr>
    <%
if not IsEmpty(Request.Form("btnTest")) then
Response.Write("<tr><td colspan=""2"" align=""center"">")
if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
else
Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
end if
Response.Write("</td></tr>" & vbCrLf)
end if
%>
</table>
</form>
</body>
</html>
bbcompent1 | Posted 1:03pm 6. May 2009 Server Time |

<%
function TestCaptcha(byval valSession, byval valCaptcha)
  dim tmpSession
  valSession = Trim(valSession)
  valCaptcha = Trim(valCaptcha)
if (valSession = vbNullString) or (valCaptcha = vbNullString) then
    TestCaptcha = false
  else
    tmpSession = valSession
valSession = Trim(Session(valSession))
  Session(tmpSession) = vbNullString
if valSession = vbNullString then
TestCaptcha = false
  else
valCaptcha = Replace(valCaptcha,"i","I")
  if StrComp(valSession,valCaptcha,1) = 0 Then
TestCaptcha = true
else
TestCaptcha = false
  end if
end if
end if
end function
%>
bbcompent1 | Posted 12:04am 7. May 2009 Server Time |

No ideas?  Nobody?  I'm really surprised...
probinu | Posted 1:18pm 22. May 2009 Server Time |

can't you just change the input type to an image?

<input type="image" name="mySubmit" src="image.jpg" >


Reply to Post Trying to style my submit button for captcha



Back to Forum Page