View Full Version : simple form errors

11-01-2004, 04:26 PM
I am trying to alter code which I have been left with to provide error messages if details are not entered correctly into an username/password retrieval form.

if the email is not valid obviously an error message gets returned,
however I am struggling with the password field, called 'membership'. If the field is valid and no corrsponding email address is found the user is sent to a contact form, but at present if we input letters instead of numbers we get a coldfusion error instaed of the java message.

the code for this is:

// function check retrieval form
function chkRetrieveForm() {
thisForm = document.getElementById("RetrieveForm");
var errorinfo = "";
var regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\"[^\"\\]+\"))@((\[(([0-1]?[0-9]{1,2}\.)|(2[0-4][0-9]\.)|(25[0-5]\.)){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var retval = true;
if (!thisForm.email.value.length && !thisForm.membership.value.length) {
retval = false;
errorinfo += "\n * Please complete either;\n\nThe E-mail field with your 'Registered E-Mail Address'\n\nor\n\nThe Membership Field with your 'Membership Number'.\n";
if (thisForm.email.value.length && thisForm.email.value.search(regex) == -1) {
retval = false;
thisForm.email.value = "";
errorinfo += "\n * Please complete the E-mail field with a valid E-mail Address.\n";
if (thisForm.membership.value.length && thisForm.membership.type) {
thisForm.membership.value= "";
errorinfo += "\n * Please enter your correct membership details or contact the IBA.\n";
if (errorinfo != "") {
errorinfo = errorinfo + "\n\n";
return retval;
// end

any help would be much appreciated.

11-02-2004, 11:49 AM
problem solved

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum