Archive for the ‘Uncategorized’ Category

A4: the validation of only numbers and letters

around 7pm, wed, 2/6/08,

i finished it.  it was so relatively easy…  but as always, you just need to be in the know.

it was a little hairy but an example of the code i ended up with was:

if((textfields.city.value == “”)||(!(textfields.city.value.match(/^[a-zA-Z]+$/))) ) { 

if statement says: if the value entered for the city is empty OR if the value entered does NOT match a lower or upper case letter, then it will return the alert box: “Please enter your city” and not continue the process.

the regular expression, as it is called, is:  /^[a-zA-Z]+$/
the backslashes “/” enclose the regular expression,
the “^” indicates the beginning of the expression,
the “[ ]” show what the range of allowed characters are which are-
lower and upper case letters,
the “$” means the end of the expression.

i’m not too sure what the “+” sign is for…

i still wasn’t able to figure out how to allow spaces within the user input.

but yeah… that was all i really needed to figure out so i must say that this assignment was done faster than normal.  especially because erik helped me out a LOT.  but i think i learned from it as well and i know that this stuff will be useful.

the only thing that really frustrates me is the divide between common laymen users and hardcore life-long programmers.  little things like the regular expression have absolutely no learning curve.  you either know about it or you don’t.  there’s no way to really know about it unless you stumble across it online or if someone flat-out tells you.  perhaps that’s something programmers really need to develop.  i know that javascript and other stuff are very people-friendly with normal language but it’s still a bit of an alien language.

javascript

interesting…  but seems to just add the fun button-clicking, things changing aspect.  doesn’t really influence the fundamental structure of the site.  something which i am intensely grateful about…

got the linking to an external javascript file…  got the popup alerts- very simple really.   it gets confusing figuring out how to make things external and not internal.  most of the examples on w3schools is internal stylesheets…

the problem i got stuck on is finding sites that explain how to switch between stylesheets that are BOTH external.  i’m finding external stylesheets and switching stylesheets but not something that tells how to do BOTH at the same time.

right now, i’m focusing on how to get the assignment done.  maybe when i have more time, i can have more fun and branch out to other interesting looking functions.  but man, it’s already down to crunch time with other classes…  i know i want to do my best in 121 but right now, it’s swallowing everything else.