Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Internet & the Web (https://www.askmehelpdesk.com/forumdisplay.php?f=177)
-   -   How do I send data to a javascript file to a java file (https://www.askmehelpdesk.com/showthread.php?t=815851)

  • Sep 3, 2015, 10:35 PM
    Ranjan kumar
    How do I send data to a javascript file to a java file
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>new user</title>
    </head>
    <body>
    <script language="javascript" type="text/javascript">


    function validate()
    {
    // get inputs
    fname = document.getElementById("fname").value;
    lname = document.getElementById("lname").value;
    email = document.getElementById("email").value;
    phone = document.getElementById("phone").value;
    pswd = document.getElementById("paswd").value;
    cpswd = document.getElementById("conpswd").value;
    country = document.getElementById("Country").value;
    //create an empty error message
    errors = "";
    //check name - It simply needs to exist
    if (fname == "")
    {
    errors += "please supply a name \n";
    } // end if
    //check email
    emailRE = /^.+@.+\..{2,4}$/;
    if (email.match(emailRE)){
    //console.log("email match");
    //do nothing.
    } else {
    //console.log(“email not a match”);
    errors += "please check email address \n";
    } // end if
    //check phone number
    phoneRE = /^\d{10}$/;
    if (phone.match(phoneRE)){
    //console.log(“phone matches”);
    //do nothing
    }
    else
    {
    //console.log(“phone problem”);
    errors += "please check phone #\n";
    } // end phone if
    //check for errors
    if(pswd==""){
    errors +="provide password"
    }
    if (errors == "")
    {
    window.location.href="http://localhost:2015/login_page/registerservlet"//process the form
    }
    else
    {
    alert(errors);


    } // end if
    } // end function
    </script>
    Enter ur Detail:<br/><br/>
    <form action="registerservlet" method="post">
    First Name:<input type="text" id=" id="><br/>
    Last Name:<input type="text" id="><br/>
    Last Name:<input type="><br/>
    Email:<input type="text" id=" id="><br/>
    phone:<input type="text" id="><br/>
    Email:<input type="><br/>
    password:<input type="text" id=" id="><br/>
    Confirm Password:<input type="text" id="><br/>
    phone:<input type="><br/>
    Country:<select id=" id=">
    <option value="india"><br/>
    password:<input type="USA" id="America"><br/>
    Confirm Password:<input type="ua" id="pak"><br/>
    Country:<select id="button">
    <option value="submit"> India </option>
    <option value="validate()"/></form>

    </body>
    </html>
  • Sep 4, 2015, 07:19 AM
    CravenMorhead
    Hi!

    Posting code, while enlightening to what you're trying to do, is almost useless because you haven't described exactly what you want to do. This also looks a lot like home work. I think you need to look at your notes and where you are in your textbook and the lessons for the answer. I've done a computer science degree, most of the time the answers are in the course material.

    If you post a more detailed explination as to what you want to do, then it should be easier to help.

  • All times are GMT -7. The time now is 02:06 AM.