I started a JavaScript course about one month ago. I really suck, lol!!!!
I?m supposed to write a script to validate Canadian postal code. I wrote the code on Notepad++ every time I try to validate the code with either IE or Firefox neither of them respond. I really don?t know if my code work or not. I?m wondering if one of you can take a look at it and tell me what is wrong and give me feedbacks, pointers, or explain me how I should write it.
My teacher wants me to put something that will change at the end the lowercase to uppercase and also to include a joint (something) to remove the space between the letters.
F.Y.I: I?m not expecting people to do my homework. BUT I truly need help, so any contribution is welcome.
Question
Batya
Hi,
I started a JavaScript course about one month ago. I really suck, lol!!!!
I?m supposed to write a script to validate Canadian postal code. I wrote the code on Notepad++ every time I try to validate the code with either IE or Firefox neither of them respond. I really don?t know if my code work or not. I?m wondering if one of you can take a look at it and tell me what is wrong and give me feedbacks, pointers, or explain me how I should write it.
My teacher wants me to put something that will change at the end the lowercase to uppercase and also to include a joint (something) to remove the space between the letters.
F.Y.I: I?m not expecting people to do my homework. BUT I truly need help, so any contribution is welcome.
Here goes nothing?lol
html>
<body>
<script language="JavaScript">
function validCodePostale(CodePostale)
{
len=CodePostale.length
nombres="0123456789"
lettres="ABCDEFGHJKLMNPQRSTUVWXYZ"
{if (lettres.indexOf(zip.charAt(0))<0)
{alert("Erreure, mettre une lettre")
break }
if(?nombres?.indexOf(entry.charAt(1))<0)
{alert("Erreure, mettre un nombre")
break }
if(?lettres?.indexOf(entry.charAt(2))<0)
{alert("Erreure, mettre une lettre")
break }
if(?nombres?.indexOf(entry.charAt(3))<0)
{alert("Erreure, mettre un nombre")
break }
if(?lettres?.indexOf(entry.charAt(4))<0)
{alert("Erreure, mettre une lettre")
break }
if(?nombres?.indexOf(entry.charAt(5))<0)
{alert("Erreure, mettre un nombre")
break }
else
{
document.write("<b>Code Postale Valide</b>");
}
</script>
</body>
</html>
Link to comment
Share on other sites
2 answers to this question
Recommended Posts