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, 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









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
calling java method from html form with out using javascript - JSP-Servlet
calling java method from html form with out using javascript  How can i call java method from a HTML form, java script should be disabled?  ...;script LANGUAGE="JavaScript">function testResults(form
Advertisements
Sending form data from HTML page to SQLserver 2005 database by calling servlet code
Sending form data from HTML page to SQLserver 2005 database by calling servlet code  Hi sir, I would like to know how to send the form data from html page to database by calling servlet code from html page .   
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 "
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
validating a form before data is entered.
validating a form before data is entered.  How can I avoid validating a form before data is entered
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
how to pass form values from javascript of html page to jsp page
how to pass form values from javascript of html page to jsp page   This is my sample html page which contains inline javascript which calculates... to submit all the form values with lattitude and longitude returned from
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
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
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 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
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..." action="login.php" onsubmit="return validate(this)"> The HTML form element... by server side script to validate the user against database. Try Login form
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
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
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
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
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
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from... through the use of DOM loading the data from another javascript file
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
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...({});   Hi, Please see the HTML form example page. Thanks
PHP HTML Form Submit Button
. The Submit button in Html is used to submit form data to the page mentioned...Topic : HTML FORM SUBMIT BUTTON Part - 4 The another part which is important... of the tutorial then our Html form has covered the action and method attribute
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
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
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
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
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
Calling Action on form load - Struts
Calling Action on form load  Hi all, is it possible to call... this list is coming from the action which i m calling before the page is being... to direct user directly to this page i m calling an action which is preparing a list
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
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
JavaScript User Defined Functions
JavaScript User-Defined Functions: An user-defined function saves  us... them to work. JavaScript has so many built-in functions, besides  that you can make your own as per the need. General structure of the user defined
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
HTML Form Validation example
HTML Form Validation example  Can anyone guide me how to validate the user name and password field in HTML using simple or JavaScript Validation. Thanks in advance!   <form method="post" onsubmit="return
Uploading file in servlet from a html form
Uploading file in servlet from a html form  Sir, I want to upload a picture from my html file and save it to my database as BLOB,but what JAR should i use for this purpose i am really confused about.And also is it possible to do
Calling Flex Function From JavaScript
From JavaScript Sometimes, you may need to call flex function from JavaScript... function callable from javascript. ExternalInterface.addCallback... </mx:Application> To Call Flex method from JavaScript do
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
Getting Json data from servlet to javascript variable
Getting Json data from servlet to javascript variable  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
Login Form
with data entered from a form on the client side. It must have setters and getters...; Login form in struts: Whenever you goes to access data from... and User Registration Application from http://www.roseindia.net
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function... to call a javascript function by passing 3 values from applet. And i have to display these values in 3 text fields of a form in the current web page. Here form
displaying data from ms excel in form.
displaying data from ms excel in form.  Hi all, I have a requirement as mentioned below: Requirement: I have stored some data in the ms excel... (for example). I need to display these data in a form. along with the actual picture
Data fetching from JSP or HTML - JSP-Servlet
Data fetching from JSP or HTML  Hi Deepak, Can u pls help me as i have a problem with jsp/html frameset. my question is how can i fetch the data from frameset which is in html format.pls help me. Thanks
Store data in HTML forms from Excel sheet
Store data in HTML forms from Excel sheet  I have a excel file having multiple coloums, and having one Html page having forms corrospoding to excel coloums. I want to auto fill up the excel data into html forms, Any one please
What is HTML Form?
to accept the data from user and then it to server for further processing. HTML/Web form is an HTML element which takes the user input in text filed, textarea... using the JavaScript. After validation of data when user clicks on the "
Calling Anonymous JavaScript Function From Flex
: #FFFFCC; } Calling Anonymous JavaScript Function From Flex In flex application, you can call javascript function defined in html file where your flex file is embed. But you can also call an anomymous javascript function

Ads