Can you guys tell me how I could inprove this code
NOnumbershere=new RegExp(/\\d/);
NOsymbolshere=new RegExp(/[+.,*ª!"·$%&()= ?¿¡º^`´ç;:_-]/);
emailpattern=new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/);
passwordpattern=new RegExp(/(?=^.{8,}$)((?=.*\\d)|(?=.*\\W+))(?![.\
])(?=.*[A-Z])(?=.*[a-z]).*$/);
warnicon = '<img align="left" src="images/warn.gif"/>';
function active_field(event)
{
event.className = "processing";
}
function check__regular_text_field(event)
{
errorid = event.id + "error";
error = document.getElementById(errorid);
thefield=event;
thevalue=thefield.value;
thevaluetolower=thevalue.toLowerCase();
firstchartoupper = thevaluetolower.charAt(0).toUpperCase() + thevaluetolower.slice(1);
thevalueint = parseInt(thevalue.length);
if (NOnumbershere.test(thevaluetolower) == true && NOsymbolshere.test(thevaluetolower) == true)
{
thefield.className = "incorrect_field";
error.innerHTML = '<?php echo $no_numbers_or_special_chars_error; ?>';
}
else if (NOnumbershere.test(thevaluetolower) == true)
{
thefield.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $no_numbers_error; ?>';
}
else if (NOsymbolshere.test(thevaluetolower) == true)
{
thefield.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $no_special_chars_error; ?>';
}
else if (thevalueint <= 1)
{
thefield.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $not_enough_chars_error; ?>';
}
else
{
thefield.className = "correct_field";
thefield.value = firstchartoupper;
error.innerHTML = "";
}
}
function check__email_text_field(event)
{
errorid = event.id + "error";
error = document.getElementById(errorid);
thefield = event;
thevalue = thefield.value;
thevaluetolower = thevalue.toLowerCase();
var x = document.getElementById("email");
var y = document.getElementById("emailc");
thevalueint = parseInt(thevalue.length);
thevalueintx = parseInt(x.value.length);
thevalueinty = parseInt(y.value.length);
if (thevalueint <= 6)
{
thefield.className="incorrect_field";
error.innerHTML = warnicon + '<?php echo $not_enough_chars_2_error; ?>';
}
else if (emailpattern.test(thevaluetolower) == false)
{
thefield.className="incorrect_field";
error.innerHTML = warnicon + '<?php echo $incorrect_email_format_error; ?>';
}
else
{
thefield.className = "correct_field";
thefield.value = thevaluetolower;
error.innerHTML = '';
}
if (x.value == "" || y.value == "")
{
x.className = "processing";
y.className = "processing";
}
else if (x.value == y.value)
{
x.className = "correct_field";
y.className = "correct_field";
}
else if (x.value != y.value && thevalueinty >= thevalueintx )
{
x.className = "incorrect_field";
y.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $incorrect_email_match_error; ?>';
}
}
function check__password_text_field(event)
{
errorid = event.id + "error";
error = document.getElementById(errorid);
thefield = event;
thevalue = thefield.value;
var x = document.getElementById("password");
var y = document.getElementById("passwordc");
thevalueint = parseInt(thevalue.length);
thevalueintx = parseInt(x.value.length);
thevalueinty = parseInt(y.value.length);
if (thevalueint <= 7)
{
thefield.className="incorrect_field";
error.innerHTML = warnicon + '<?php echo $not_enough_chars_3_error; ?>';
}
else if (passwordpattern.test(thevalue) == false)
{
thefield.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $incorrect_password_format_error; ?>';
}
else
{
thefield.className = "correct_field";
error.innerHTML = '';
}
if (x.value == "" || y.value == "")
{
}
else if (x.value == y.value)
{
x.className = "correct_field";
y.className = "correct_field";
}
else if (x.value != y.value)
{
x.className = "incorrect_field";
y.className = "incorrect_field";
error.innerHTML = warnicon + '<?php echo $incorrect_password_match_error; ?>';
}
}
Here is a link to the working code
Thanks