Calling In JavaScript Functions from HTML Form To Validate User Entered Data

Ads
 

Calling In JavaScript Functions from HTML Form To Validate User Entered Data

Hello, I have been working for days on my web Form assignment and editing my html to call my functions to validate the user entered data, but to no avail.I finally decided to place the functions in the head. But, I still cannot make a call. Below is my code. Please help. Thanks in advance.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Subscription Form</title>
<script type="text/javascript">
function validateSubscriptionForm () {
    //declare variables to check if textfields are blank
    var blankEmail=chkEmail ();
    var blankFname=chkFN ();
    var blankLname=chklN ();
    var blankAddr=chkAddr ();
    var blankCity=chkCity ();
    var blankSt=chkSt ();
    var blankZipCode=chkZ ();
    var blankTel=chkTel ();
}

function chkEmail (){
    if (document.Subscription_Form.getElementById("eMailTextField").value == "") {
        alert("Please fill in required e-mail address");
        document.Subscription_Form.eMailTextField.focus();//repositions the cursor back to the email textfield
        }
}

function chkFN () {
    if (document.Subscription_Form.getElementById("firstNameTextField").value == "")    {
        alert("Please fill in required First Name");
        document.Subscription_Form.firstNameTextField.focus();
        }       
}

function chklN (){
    if (document.getElementById("lastNameTextField").value == "")   {
        alert("Please fill in required Last Name");
        document.Subscription_Form.lastNameTextField.focus();
        }
}

function chkAddr (){
    if (document.getElementById("addressTextField").value == "")    {
        alert("Please fill in required Address");
        document.Subsciption_Form.addressTextField.focus();
        }
}

function chkCity() {
    if (document.getElementById("cityTextField").value == "")   {
        alert("Please fill in required City");
        document.Subscription_Form.cityTextField.focus();
        }
}

function chkSt () {
    if (document.getElementById("stateTextField").value == "")  {
        alert("Please fill in required State");
        document.Subscription_Form.stateTextField.focus();
        }
}

function chkZ (){
    if (document.getElementById("zipCodeTextField").value == "")    {
        alert("Please fill in required Zip Code");
        document.Subscription_Form.zipCodeTextField.focus();
        }
    if (isNaN(zipCodeTextField.value) == true) {
    alert("Please enter a valid Zip Code Number");
    zipCodeTextField.focus();
    zipCodeTextField.select();
    }   
}

function chkTel () {
    if (document.getElementById("telephoneTextField").value == "")  {
        alert("Please fill in required Telephone");
        document.Subscription_Form.telephoneTextField.focus();
        }
}
</script>
<link href="form_style_1.css" rel="stylesheet" title="Subscription Form Style 1" type="text/css" />
<!--create script to link this subscription form to the acknowledgement page -->
</head>

<body>
<!--insert form and design form layout with a header -->
<form name="Subscription_Form" action="" method="post"  id="form1"><!--form1 sets style of subscription form-->
<h1>Subscription Form</h1>
<p align="center">The <span style="color:#F00">*</span> denotes required information</p>
<p>
    <label><span style="color:#F00"> * </span> Email: </label>
    <input style="position:absolute; left: 116px;" type="text" size="30" align="right" id="eMailTextField" onclick="chkEmail()" /><br />
    </p>
<p> 
    <label><span style="color:#F00"> * </span> First Name: </label>
    <input style="position:absolute; left: 116px;" type="text" size="30" align="right" id="firstNameTextField" /><br />
</p>
<p>  
    <label><span style="color:#F00"> * </span> Last Name: </label>
    <input style="position:absolute; left: 116px;" type="text" size="30" align="right" id="lastNameTextField" /><br />
</p>
<p>  
    <label><span style="color:#F00"> * </span> Address: </label>
    <input style="position:absolute; left: 116px;"  type="text" size="30" align="right" id="addressTextField" /><br />
</p>
<p>    
    <label><span style="color:#F00"> * </span> City: </label>
    <input style="position:absolute; left: 115px;" id="cityTextField" type="text" size="30" maxlength="30" /><br  />
</p>
<p>  
    <label><span style="color:#F00"> * </span> State: </label>
    <input style="position:absolute; left: 116px;" type="text" size="2" maxlength="2" align="right" id="stateTextField" /><br />
</p>
<p>
    <label><span style="color:#F00"> * </span> Zip Code: </label>
    <input style="position:absolute; left: 116px;" type="text" size="5" maxlength="5" align="right" id="zipCodeTextField" /><br />
</p>

<p> 
    <label><span style="color:#F00"> * </span> Telephone: </label>
    <input style="position:absolute; left: 116px;" type="text" size="30" maxlength="30" align="right" id="telephoneTextField" /><br  />
</p>

<input style="position:absolute; left: 188px;" type="submit" value="Submit" onclick="validateSusbscriptionForm()" />
View Answers

Ads









Related Tutorials/Questions & Answers:
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered Data  Hello, I have been working for days on my web Form assignment and editing my html to call my functions to validate the user entered data
How to display user entered information using HTML and JavaScript
How to display user entered information using HTML and JavaScript. We are going to describe How to display user entered information using HTML and JavaScript. First of all we have created HTML form with two text fields "
Advertisements
to store data entered in html page
to store data entered in html page  i want to a job site, in this site user can registered by a form.. in this form there are his information... i... submit we have to move to form 2 on there we have enter text data
How do i validate form using javascript and send data to database?
How do i validate form using javascript and send data to database?  I need a "JOIN US" form that can validate using javascript and be able to connect with and post data into a database. The details to be validated and posted
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
Error in calling javascript function from java
Error in calling javascript function from java  I am callin javascriot function from applet and getting error netscape.javascript.JSException: Unexpected error: This method should not be used unless loaded from plugin.jar
Calling java class method from javascript
Calling java class method from javascript  I want to call a java class method from javascript. The java class method is like "public String[] getWord()". I want to assign this string array value to a variable in javascript. I
Restricting the user from filling the data in a textfield using html
Restricting the user from filling the data in a textfield using html  I got a requirement like this, If the user is trying to fill a text field, i have to restrict him
write a javascript progam to implement functions in html
write a javascript progam to implement functions in html  write a javascript progam to implement functions in html  Please visit the following link: http://www.roseindia.net/javascript/emailvalidation.shtml http
how to send smtp mail to entered user mail id after user registered using javascript?
how to send smtp mail to entered user mail id after user registered using javascript?  how to send smtp mail to entered user mail id after user registered using javascript
how to send smtp mail to entered user mail id after user registered using javascript?
how to send smtp mail to entered user mail id after user registered using javascript?  how to send smtp mail to entered user mail id after user registered using javascript
Process HTML FORM data
Process HTML FORM data  Can a JSP page process HTML FORM data?   Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick
How to create simple HTML Login Page?
it with JavaScript If you are learning HTML form then this can be your first tutorial...(this)"> The HTML form element is used to submit the form data to the server... script to validate the user against database. Try Login form: try the Simple
How to create simple HTML Login Page?
it with JavaScript If you are learning HTML form then this can be your first tutorial...(this)"> The HTML form element is used to submit the form data to the server... script to validate the user against database. Try Login form: try the Simple
how to validate the telephone number without using jquery in html with javascript
how to validate the telephone number without using jquery in html with javascript  how to validate the telephone number without using jquery in html with javascript
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details... from form and stores it in User--%> String Pword = request.getParameter
Hi how to transfer table data from html page to excel sheet by using javascript .
Hi how to transfer table data from html page to excel sheet by using javascript .  html page to excel sheet by using javascript and i dont want to transfer all rows in table, i want to hide some rows in excel sheet. Please send
Html form using JavaScript to display the table content
Html form using JavaScript to display the table content  HI There, Greetings, I am new to this java and I need your assistance. I have created... want to write a Html JavaScript coding to display the content from database
How can I dynamically load user-entered data as content of jquery dialog?
How can I dynamically load user-entered data as content of jquery dialog? ... the value of user-entered name to show in the dialog content. I am also trying to echo this from a php file where my form is validated. Below is my code. Thanks
extract data from HTML
extract data from HTML  how to write the coding for to extract data from html tags like(h3,p) and then extracted data should be stored in data base? can anybody tell me how to write the coding
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
HTML form examples
HTML form examples  Hi, How to create a simple data entry form in HTML and use JavaScript to validate the same. Can anyone share html form examples code? Thanks   Hi, Please see the HTML form example page. Thanks
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval... file.How can i store data entered by user in XML file and later retrieve data... by user to be stored in xml file.here you have entered data in JSP file
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
how to display data from database according to entered value in search field
how to display data from database according to entered value in search..."); if(data != "bmi_value"){ %> <script language="javascript">..., so i want the data of user who have 17 as their bmi value to appear. help me
How to store data entered by User in JSP page in XML file
How to store data entered by User in JSP page in XML file  How to store data entered by user in JSP page to be saved in XML file.On clicking submit button data entered by a user in a page must be saved in XML file.How to do so
Getting data from servlet into javascript
Getting data from servlet into javascript  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript  Here is the HTML code to create text boxes dynamically. It works properly.... And also how to validate the text boxes created dynamically. <html>
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how to validate your application form in javascript. In many applications data is accepted through the application form. To specify that the data which has been
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array..., To get an array values from the html form you can use the getParameterValues

Ads