Jump to content


<input type="image"

  • Please log in to reply
2 replies to this topic

#1 StirCrazy

  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 04 August 2006 - 09:28 PM

I've attached the basics of the Registration page i'm working with.

My problem is that when when I use <input type="image"
If some of the registation fields are empty and press 'submit' I get an alert but then it refreshes the screen.
I don't want it to refresh (coz I lose all the information already entered).

When I use <input type="button" this doesn't happen.

Does anyone know why it refreshes?

Cheers folks,

<script language="javascript">
  function check_fields(regform) {
    errIndicator = 0;
    for (i = 1; i<11; i++) {
      if ("" == regform.elements[i].value) {
        errIndicator = 1;

    if (errIndicator) {
      alert("Please fill in all fields");
      return 1;

    if (regform.email.value != regform.email2.value) {
      alert("E-Mail Confirmation Failed");
      return 3;

    if (regform.country.value == "no") {
      alert("You must choose your country");
      return 4;
    if (regform.agree.checked == false ){
alert('Please accept our Terms of service to continue.');
	  return 5;


    return 0;

<form name="regform" action="index.php?page=register3" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div align="center">

<!------- CODE HERE --------->

<br><center><span class="AcceptTos">
I certify that <b>I am a U.K. Resident over the age of 18, and<br>
I agree to the</b> <a class="AcceptTos" href="javascript:popup('tos.php')">Terms of Service</a>: <input type="checkbox" value="0" name="agree"></span>
<input type="image" src="images/layout/submit.gif" onclick="check_fields(regform);" value="  Sign Up  "></center>



#2 hegtv

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 August 2006 - 02:54 AM

<input type="image"> acts as a submit button, so when you click on it, the form is being immediately submitted.  You could try just using an <img>, with the same onClick parameter as your <input type="image"> OR you could change



onclick="check_fields(regform); return false;"

and leave it where it is.  Either should work fine.

Hope that works for you.

#3 StirCrazy

  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 05 August 2006 - 03:54 PM

nice one hegtv ~ onclick="check_fields(regform); return false;" works great.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users