![]() |
Javascript validation problems
Hey guys, im a bit of a loser with Javascript and need a bit of validation done but I have no idea what the problem is with my code, can anyone help?
Form: Code:
<div id="Layer3">Im sure there are a few syntax errors but any and all help is greatly appreciated :) |
When posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.
Have you tried to identify syntax errors with your error console or better still Firebug? Your UK postcode validator can be simplified and improved with a regex:- if(/((^(A[BL]|B[ABDHLNRST]|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]|F[KY]|G[LUY]|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]|M[EKL]|N[EGNPRW]|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKL-PRSTWY]|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)\d\d?)|(^W1[A-HJKSTUW0-9])|(^WC[1-2])|(^EC[1-4])|(^SW1[ABEHMNPRVWXY])|(^GIR\s?0AA))(\s\d[ABDEFGHJLNPQRSTUWXYZ]{2})$/.test(postcode.value)) { NB: Letters C, I, K, M, O and V are never used in the incode. Postcode must be in upper-case. Quizmaster: Which animal do we get vension from? Contestant: Snakes. |
Oky, cheers for the help, unfortunately I have no idea how to use firebug :(
And how do I implement that piece of code? As basically the second time I have used meaningful javascript I'm not exactly compitent yet. Many Thanks |
Can anyone help? sorry about the double post but I really need this sorted
|
You are not calling your validation script anywhere.
<input type="submit" name="Submit" value="Submit" /> You could have found this out just by putting in an alert. Code:
function formValidator(form){Code:
<input type="submit" name="Submit" value="Submit" onsubmit = return formValidator(this.form){/> |
| All times are GMT +1. The time now is 03:50 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.