I have a problem. I have a form and before sending the information I have to change the phoennumber format. For example, if a user enters 333-333-3333, I have to get rid of the character "-". I know how to do that, but it doesn't take it. This is my code:
function validForm() {
var stripped;
var msg="";
var result = true;
var phoneval = document.cust_name_addrs.phone.value;
var faxval = document.cust_name_addrs.fax.value;
//strip out acceptable non-numeric characters
if ( phoneval == "" ) {
msg = msg + 'Please enter your Phone Number\n';
result = false;
} else if ( faxval == "" ) {
msg = msg + 'Please enter your Fax Number\n';
result = false;
if (!result)
alert(msg);
document.cust_name_addrs.phone.value = document.cust_name_addrs.phone.value.replace(/[\(\)\.\-\ ]/g, '');
return result;
}
When I submit the form it doen't change the value, only if there is an error it changes, otherwise it sends the info with the "-". Other problem is that when it finds and error it shows the phone without the "-".
Hope sompeone helps. Bye
function validForm() {
var stripped;
var msg="";
var result = true;
var phoneval = document.cust_name_addrs.phone.value;
var faxval = document.cust_name_addrs.fax.value;
//strip out acceptable non-numeric characters
if ( phoneval == "" ) {
msg = msg + 'Please enter your Phone Number\n';
result = false;
} else if ( faxval == "" ) {
msg = msg + 'Please enter your Fax Number\n';
result = false;
if (!result)
alert(msg);
document.cust_name_addrs.phone.value = document.cust_name_addrs.phone.value.replace(/[\(\)\.\-\ ]/g, '');
return result;
}
When I submit the form it doen't change the value, only if there is an error it changes, otherwise it sends the info with the "-". Other problem is that when it finds and error it shows the phone without the "-".
Hope sompeone helps. Bye