Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handling on Same Page

Status
Not open for further replies.

lakeside12

Programmer
Apr 20, 2009
43
CA
hi
I apologize for starting a new thread, it was just too convoluted to add this in....

Question:Is there a way to use this on form validation method (below) in a hyperlinked method i.e when you click the hyperlink it verifies the form before executing the hyperlink to the next page

FORM VALIDATION BELOW WORKS (from this forum thank you)

Code:
<form xyz...    onSubmit="return checkme(this)"> 
....
......

function checkme(what)
{
  var err=''
  if (!what.PhoneDay.value.match(/^[0-9]{11}$/)) err+='\n - Your Phone number must be 10 digits e.g. 905 505 1122'
  if (!what.Zipcode.value.match(/^[0-9]{5}$/)) err+='\n - Your zip code must contain 5 correct digits'
  if (!what.FirstName.value.length) err+='\n - first name must be completed'
  if (!what.LastName.value.length) err+='\n - Last name must be completed'
  if (err) alert('Errors occured :'+err)
  return err==''
}

Any errors on the form prevent it from being submitted - Perfect!

REASON: I need to have my own Submit Button graphic, not the standard HTML one, and I do not know how to change that standard HTML submit button, not sure that is possible, hence my attempt to use a hyperlink instead.

Many thanks
 
You can do 3 things:

1. Use an image input. This means you can keep the onSubmit event on your form. Image buttons act like regular submit buttons, but yo can assign them an image.

Code:
<input type=image  src="mybuttonimage.jpg">

Or

2. If you must use a hyperlink, use it to call the onSubmit method of the form after all validation has occurred and has passed.

3. Use CSS to style the submit button and give it an image.

I'd suggest using the8image input, as its the most straight forward method, and it will validate.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top