argh! js form validation - doing my head in!!!
What I am trying to achieve sounded so easy in principle but the more I read up on it the worse I got and have ended up not knowing whether I am coming or going :confused:
Okay I have a html form (simple search and advanced search screens) I need to check that of the field that are completed they must be at least 2 characters in length and must contain an alphanumeric value.
so what I have got is this:
code on my form
and then in JS code I have this (kind of)
onSubmit="return checksearchdata(this)" name=f1
I am doubting the min length as I am looking at (obj) rather than field.length.. I already check previously that at least one field in filled in, so its only to check the filled in fields are 2 digits min etc etc
var formObj = f1code;
var codeReg = new RegExp(/[a-z][0-9]/)
alert("Your data is not valid for the "+formObj.name);
var min = 2;
if (!field.value || field.value.length < min)
please help and please don't laugh