Question : Redirecting Users Based on Input

I need to validate some code that will be entered on a form - mainly the phone number and it should be 10 digits.  I looked at a few sites but the code they provided did not really help me.  

I need to verify the number is a ten-digit number without the hyphens.  If they enter the hyphens (or dashes) like 800-555-1212, a dialog box should come up asking them to remove the hyphens.  

If they enter another phone number that is longer than 10 digits, they should be re-directed to a specific page.  The page can be found at

I can use ASP as well if someone has a better code.  Thanks!

Answer : Redirecting Users Based on Input

Here is an example of how you can achieve the validation requirement and redirect the page to the desired URL. Let me know if you face any issues.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
        function validate(){
            var phoneNo = document.getElementById('phone').value;
            var url = "";
            if(phoneNo.length == 0){
                  alert('Please Enter Phone Number');
                  return false;
            if(phoneNo.indexOf("/") > -1 && phoneNo.indexOf("-") > -1){
                  alert('Please Remove Slash And Hyphen');
                  return false;
            if(phoneNo.indexOf("/") > -1){
                  alert('Please Remove Slash');
                  return false;
            if(phoneNo.indexOf("-") > -1){
                  alert('Please Remove Hyphen');
                  return false;
            for (var i=0; i<phoneNo.length; i++) {
                  if ("0123456789".indexOf(phoneNo.charAt(i)) == -1) {
                        alert('Please Enter Numbers Only');
                        return false;
            if(phoneNo.length > 10){
                  return false;
            return true;

       <form onSubmit="validate()" action="#">
            <input type="text" id="phone"/>
            <input type="submit"  name="submit"/>
Random Solutions  
programming4us programming4us