ExpDisease
26 Aug 2010, 07:33 AM
I cannot get the result right. I write area and phone by numbers but it still gives me error
function validate_text(field,alerttext) {
with(field) {
var re = /[a-zA-Z]/g;
if(re.test(field)) { return true;}else{alert(alerttext);return false;}
}
}
function validate_number(field,alerttext){
with(field) {
var re = /[0-9]/g;
if(re.test(field)) { return true;}else{alert(alerttext);return false;}
}
}
function validateForm(thisForm){
with(thisForm)
{
if(validate_number(area,"wrong area code") == false) {
area.focus();return false;
}
if(validate_number(phone,"wrong phone") == false) {
phone.focus();return false;
}
if(validate_text(name_surname,"wrong name") == false) {
name_surname.focus();return false;
}
}
}
...<b>Name Surname :</b><input style="margin-left:10px;" type="text" name="name_surname"/>
<br /><br />
<b>phone :</b><input type="text" style="margin-left:19px;" maxlength="4" size="4" name="area" />
-<input type="text" style="margin-left:5px;" maxlength="7" size="10" name="phone" /><br /><br />....
function validate_text(field,alerttext) {
with(field) {
var re = /[a-zA-Z]/g;
if(re.test(field)) { return true;}else{alert(alerttext);return false;}
}
}
function validate_number(field,alerttext){
with(field) {
var re = /[0-9]/g;
if(re.test(field)) { return true;}else{alert(alerttext);return false;}
}
}
function validateForm(thisForm){
with(thisForm)
{
if(validate_number(area,"wrong area code") == false) {
area.focus();return false;
}
if(validate_number(phone,"wrong phone") == false) {
phone.focus();return false;
}
if(validate_text(name_surname,"wrong name") == false) {
name_surname.focus();return false;
}
}
}
...<b>Name Surname :</b><input style="margin-left:10px;" type="text" name="name_surname"/>
<br /><br />
<b>phone :</b><input type="text" style="margin-left:19px;" maxlength="4" size="4" name="area" />
-<input type="text" style="margin-left:5px;" maxlength="7" size="10" name="phone" /><br /><br />....