Really basic form validation

As I know this will help someone, here’s a simple way to use form validation.

One important bit: The function to go in the <head>.

[code lang=”js”]


And make sure you text boxes have an "ALT" attribute, like this for example:
<input type="text" name="fname" id="fname" alt="First Name" />
Important! Only put an ALT attribute for the required inputs!

Finally, tuck this little bit into your <form> tag you want to use:
<form name="contactform" onsubmit="return(checkForm(this));" method="..  >

Processing Forms with JavaScript

Occasionally you can’t use server-side languages to deal with form input. In my case it’s because my university coursework assignment had to be done in JavaScript, but who knows what your reasons could be.

This snippet of code has a few good points:

  • It’ll take standard forms with no javascript and parse the inputs.
  • You can use the GET method to send the data.
  • It’s simple, short and cross-browser compatible.

And some bad..

  • You can’t handle submitted files (not really tested it though)
  • You can’t do things with POST’ed forms.
  • You really shouldn’t be processing anything important on the client-side, as it’s open to a multitude of attacks.

But anyway, I shall walk you through my thinking…

Continue reading Processing Forms with JavaScript

Search box friendly-ness

A way to save space, but still make your search box clear and usable.

This is a simple addition to have the search box ( or whatever you like really! ) contain the label for the input box. In this instance, you can have the text in the search box disappear when you click it.

In your <head> tag:
[code lang=”js”]

And on your text box:

[code lang=”html”]


A way to save space, but still make your search box clear and usable.