Home Answers Viewqa JavaScriptQuestions Calling In JavaScript Functions from HTML Form To Validate User Entered Data

 
 


Mike Lee
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
0 Answer(s)      4 months and 24 days ago
Posted in : JavaScript Questions

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 Pages:
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
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
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
Calling Action on form load - Struts
; This action needs no data other than the user's session, which it can get from...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
jQuery to validate Email Address
that validate the email address  from server and displays on the user browser... (data) { if data equals to "error1"  It means You not entered... jQuery to validate Email Address     
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
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 .   
JavaScript Functions
to validate email address. Built-in functions JavaScript provides many built... JavaScript Functions   ... the JavaScript functions. What is JavaScript Function? Java script Function
HTML form example
HTML form example In this section we will develop HTML form example and show you how to performance form validation using JavaScript. The HTML <form>... user and then validate it. Here is the code of the same: <!DOCTYPE HTML
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
Javascript Examples
validate an email address for a formjavascript focus input JavaScript can be very useful while the user fills the form containing number of fields... where the user came from. JavaScript provides several methods for this purpose. 
JavaScript - JavaScript Tutorial
functions via javascript: URLs Conditionally navigating the user... but experienced programmer can also learn many things from this JavaScript tutorial series... how to immediately put JavaScript to validate forms, calculate values, work
PHP HTML Form Submit Button
in Html is used to submit form data to the page mentioned in the ACTION attribute... values from the text box in the Html form...Topic : HTML FORM SUBMIT BUTTON Part - 4 The another part which is important
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
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
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
php $_GET and $_POST functions
are used to get the values which are passed from a user-filled form, like user... of that whenever we send data from one web page to another using $_GET variable we... php $_GET and $_POST functions:      
Login Form
on the server side with data entered from a form on the client side. It must have setters...; Login form in struts: Whenever you goes to access data from... and User Registration Application from http://www.roseindia.net
JavaScript validate select tag
JavaScript validate select tag In this tutorial, you will learn how to validate html select tag. Here, we have used two select tags to select numbers in order to calculate addition of two numbers. If the user does not select any
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
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
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 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
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
Validate
Validate   hi all..im a beginner java and i need some help from u guys.. Its about validate. My HR request BF = 'brought forward', leave cannot apply date greater than 31/03 of particular year. So, if the user apply the date
form validate and perfom action immediatly
form validate and perfom action immediatly  This is ok, but what i'm looking for is whenever a user input different data his input has to validate..." for Age in a form then he needs to redirect him to some web page like
VALIDATE
one application inthis application by using jsp file to crate a form by using that form i can enter the data it will connect to business logic and the inserted... have some problem that is i want see the previously enterd data in a form page
JavaScript - JavaScript Tutorial
functions via javascript: URLs Conditionally navigating the user to a page... from this JavaScript tutorial series. This JavaScript Tutorial will teach you..., functions, etc. You will also learn how to immediately put JavaScript
JavaScript - JavaScript Tutorial
functions via javascript: URLs Conditionally navigating the user to a page... from this JavaScript tutorial series. This JavaScript Tutorial will teach you..., functions, etc. You will also learn how to immediately put JavaScript
HTML
Button in HTML are type of input form, which allows a user to select any one... of all file, when a user click on browse button A form in an HTML (web page) contain... will learn about the basic tags of a HTML Form and their attributes.  
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
PHP HTML Form
will take user's name and city from a html file and display those information... a HTML form and send the data to PHP file get method. ...PHP & HTML Form: In the current tutorial we will study about PHP and HTML
Tomahawk validateCreditCard tag
is used to validate a Credit Card Number entered by the user. If we want the user to enter a valid Credit Card Number then this validation...; If the number entered by the user is not valid then error message is displayed
Html
Html  can we send data from one html page to another html page? if yes how?   Yes, using javascript. 1)page1.html: <html> <form...: <html> <script LANGUAGE="JavaScript"> function getParams() { var idx
JavaScript array functions sort
JavaScript array functions sort   ... to understand the concept of JavaScript array function sort. The code create a HTML Page specifying Name, text field and  button 'Insert and sort
User Registration Form Using JSP(JspBeans)
User Registration Form Using JSP(JspBeans)  ... of user registration form using jsp. One of the basic programming tactics... for processing form data, you can follow a common design pattern by matching the names
html - Development process
html  Write a HTML page containing an HTML form to capture the following properties from the user: a. Name (text box) b. Address (text area) c. Phone (text box) Write javascript functions 1.to validate Name
Calling a jsp page from Servlet
Calling a jsp page from Servlet  How can I do this? Suppose I have jsp page aaa.jsp. From aaa.jsp on form action I have made a call to a servlet xxx.java. In xxx.java I have written code to retrieve data from database through
Registration Form
Date of birth from Drop down to database and how to validate user entered String...Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data
HTML Post Form
to send the form data in the form of message. The Post method in HTML is used... an example from HTML Post Form. In this Tutorial, the code explain you a post... is used to transfer the data in encoded form and the user is not able to see
javascript
; </HEAD> <form name="f1" onsubmit ="return validate();"> <SELECT...javascript  <HTML> <HEAD> <TITLE>validate <Script language = JavaScript> function validate(theForm) { var why=""; why
Developing User Registration Form
Developing User Registration Form   ... necessary to develop the User Registration Form for our Struts, Hibernate and Spring... how to develop the User Registration Form and related JSP files. This User
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 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
Updating user profile
profile with edit option including entered data by user should be shown in jsp page fileds   The given code retrieve data from database and display.... When the user clicks the particular edit button, that data will get shown
Develop user registration form
retrieved from the registration form. To stored the data into the database it uses... User Registration Form in JSP     ... registration form which will insert  the entered  data into the database
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
HTML form - Java Beginners
HTML form   Hi, thank u for fast reply. I have two forms (form1 and form 2)with several fields in html. When i click the submit button, it validates all fields then moves to form2. i have a problem with form navigation. i
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
Tomahawk validateRegExpr tag
to validate a string entered by the user. If we want the user to enter... for that component. For example, we have an input field and we want the user to enter... to specify the pattern to be followed by the user to input the string