Home Answers Viewqa PHP PHP JavaScript form Validation

 
 


Java Coder
PHP JavaScript form Validation
2 Answer(s)      2 years and 8 months ago
Posted in : PHP

Just looking for a general PHP JavaScript form Validation. How can I write external JavaScript Validation? Please suggest!
View Answers

October 6, 2010 at 11:53 AM


Hi Friend,

1) form

<html>
<script src="validateForm.js">
</script>
<form name="form" method="post" onsubmit="return validate();">
<table>
<tr><td>Enter Name</td><td><input type="text" name="name"></td></tr>
<tr><td>Enter Address</td><td><textarea rows="4" cols="8" name="address"></textarea></td></tr>
<tr><td>Gender</td><td><input type="radio" name="radio">M<input type="radio" name="radio">F</td></tr>
<tr><td>Qualification</td><td><select name="qua"><option value="BTech">BTech</option><option value="BTech">MBA</option><option value="BTech">MCA</option><option value="BTech">MTech</option></select></td></tr>
<tr><td>Specialization</td><td><select id="specialization" name="specialization" multiple="multiple" ><option value="Software">Software</option><option value="Hardware">Hardware</option><option value="Electrical">Electrical</option><option value="Mechanical">Mechanical</option><option value="Finance">Finance</option><option value="Finance">Marketing</option></select></td></tr>
<tr><td>Languages</td><td><input type="checkbox" name="lang1" value="Hindi">Hindi<input type="checkbox" name="lang2" value="English">English<input type="checkbox" name="lang3" value="French">French<input type="checkbox" name="lang4" value="German">German</td></tr>
<tr><td><input type="submit" value="Submit" ></td><td><input type="reset"></td></tr>
</table>
</form>
</html>

October 6, 2010 at 11:54 AM


continue..

2)validateForm.js:

function checkName(text) {
if(isNaN(text)){ return 1;}
else{alert("Please enter a valid name. The only charachters accepted are A - Z and a - z");return 0;}
}
function checkAddress(text) {
if(isNaN(text)){ return 1;}
else{alert("Please enter a valid address. The only charachters accepted are A - Z and a - z");return 0;}
}
function validate(){
if (document.form.name.value == ""){
alert ( "Please enter name." );
document.form.name.focus();
return false;
}
if (checkName(document.form.name.value)==false){
name.value=""
name.focus()
return false
}
if (document.form.address.value == ""){
alert ( "Please enter address." );
document.form.address.focus();
return false;
}
if (checkAddress(document.form.address.value)==false){
address.value=""
address.focus()
return false
}
if ( ( document.form.radio[0].checked == false ) && ( document.form.radio[1].checked == false ) ){
alert ( "Please choose Gender: M or F" );
document.form.radio[0].focus();
return false;
}
if ( document.form.qua.selectedIndex == 0 ){
alert ( "Please select Qualification." );
document.form.qua.focus();
return false;
}
if(!multiselect_validate(document.getElementById('specialization'))){
alert ( "Please select Specialization." );
return false;
}
if ((document.form.lang1.checked == false) &&(document.form.lang2.checked == false) &&(document.form.lang3.checked == false)&&(document.form.lang4.checked == false))
{
alert ('You didn\'t choose any of the checkboxes!');
return false;
}
var n=document.form.name.value;
var add=document.form.address.value;
document.writeln("Name= "+n);
document.writeln("");
document.writeln("Address= "+add);
var oRadio = document.forms[0].elements[radio].value;
document.write(oRadio);
return true;
}
function multiselect_validate(select) {
var valid = false;
for(var i = 0; i < select.length; i++) {
if(select.options[i].selected) {
valid = true;
break;
}
}
return valid;
}

Thanks









Related Pages:
PHP JavaScript form Validation - PHP
PHP JavaScript form Validation  Just looking for a general PHP JavaScript form Validation. How can I write external JavaScript Validation? Please suggest!  Hi Friend, 1) form Enter Name Enter Address
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
form validation
form validation  how the form validation is done in jsf form using javaScript
Custom Form Validation - PHP
Custom Form Validation  Which is the best way or where should I implement the custom validation rules such as ? using number, capital letters and symbols to secure the password
Form Validation with JavaScript
Form Validation with JavaScript  I created a simple form including nine or ten fields in HTML, and i want to validate it in JavaScript. How can i do...: <html> <script src="validateForm.js"> </script> <form
javascript form validation
javascript form validation  How to validate radio button , dropdown list and list box using onsubmit event..please give me a sample example..If we do...; } return true; } </SCRIPT> </HEAD> <form name="f1" onsubmit
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions..." language="javascript"> </script> <body> <form name="form
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
PHP Form Part-1
Topic : HTML FORM Part - 1  In this tutorial, we will learn how to deal with Html Form, JavaScript Validation, MySQL Database and PHP Scripts. We... start with Html Form : If you have little bit  knowledge about Html
Form Validation With Java Script
Form Validation With Java Script   ... the Validation in  JavaScript and  your Validation in JavaScript program... information are entered to the users in the form fields before submission
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g....;Have a look at the following link: JQuery Form Validation The above link provide
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g....;Have a look at the following link: JQuery Form Validation The above link provide
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... am giving a simple example for form validation using Javascript. Example
Check Box Validation in PHP - PHP
Check Box Validation in PHP  How can validations done on check boxes more than 3?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/javascript-array/javascript-array-checkboxes.shtml
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">...(); } </script> </head> <body> <FORM name
javascript
javascript  Hi deepak, how to write form validation on javascript
PHP HTML Form
PHP & HTML Form: In the current tutorial we will study about PHP and HTML form, we will see how to send HTML . We will combine one html file and PHP... the coding by your own, by putting some validation using JavaScript file. We
JavaScript Email Validation
JavaScript Email Validation...; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms
javascript form submission
javascript form submission  how can apply validation when doing submission like following <html> <script type="text/javascript...(); } </script> <form id="myform" action="submit-form.php
Form validation Using Jquery Plugin
Form validation Using Jquery Plugin  Hello sir I want to implement form validation using JQuery Plug-in. My code is : <html> <style type...; } .form-row { padding: 10px 0; clear: both; width: 800px; } label.error { width
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
combox validation javascript code - JSP-Servlet
combox validation javascript code  hiiiiiii, I want a javascript code for combobox field validation for my Lotus Notes web page.... thnx  Hi This is the source code of combobox validation in javascript
form validation
form validation  <form name="form" method="post" action="process.php" onsubmit="return validate(); "> <table align="center" border="1px... want validation code,username minimum 8 char,password length must >6,and one
On Javascript
On Javascript  Design a job registration form using HTML and CSS... and experience details to apply for a job. Do proper validation for all mandatory fields, Example. to check for blank field, number validation for salary, mobile
Form validation
Form validation  Hi Everyone Can someone assist me with a complete code to validate a form. e.g where the user must insert an ID number it should check if the user entered the correct data and within a valid range. This must
date validation
date validation  sir, pls provide date validation code in javascript..we want to include it into our master form..   Please visit the following link: http://www.roseindia.net/mysql/datevalidation.shtml
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
Javascript
Javascript  in the web form the phonenumber field should be like this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
PHP Sticky form problem
PHP Sticky form problem  I have done the full coding of a sticky form... Calculator</title> <?php if (isset($_POST['submitted']) &&...; } ?> <script type="text/javascript"> </script> <
PHP Sticky form problem
PHP Sticky form problem  I have done the full coding of a sticky form... Calculator</title> <?php if (isset($_POST['submitted']) && !isset...']." = ".$divide; } ?> <script type="text/javascript">
string validation in php - PHP
string validation in php  Can you please post a example of PHP Built-in String Validation Functions
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put. otherwise call the javascript onsubmit to check value of radiobutton and file
Help needed for Form Validation please help!
Help needed for Form Validation please help!  I have created a page... to the login submit button. <html><form name=f1 method=POST action...;/font>Â Â <script type="text/javascript"> function validateForm() { var x
Please provide jquery inline form validation for the code
Please provide jquery inline form validation for the code   <...="text/javascript" src="Datetimepicker.js"></script> <body bgcolor="white"> <form action="Student1Servlet" method="post" enctype="multipart/form
Form Validation using Regular Expressions is JavaScript
Form Validation using Regular Expressions is JavaScript... is JavaScript validation using Regular Expressions? The JavaScript Validating... to the lack of useful intrinsic validation functions in JavaScript. JavaScript 1.2 has
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class...; </table> <div style="text-align:center" class="form-buttons
javascript
javascript  Hi deepak, sample example on javascript form validation... ."); document.form.contactNo.focus(); return false; } } </script> <form name="form" method="post" onsubmit="return validate();"> <table> <
validation
form using spring ,hibernate and jsp my all classes and jsp pages are pasted here when i try to validate my form its says invalid property'validater of ur...="ISO-8859-1"%> <%@ taglib uri="http://www.springframework.org/tags/form
Validation
javax.swing.*; import java.awt.event.*; class Form extends JFrame { JButton ADD; JPanel panel; JLabel label1,label2; final JTextField text1,text2;; Form...(panel); setTitle("FORM"); ADD.addActionListener(new ActionListener() { public void
Validation
Validation  Here is my form and what code should i write for validating it? - <form action="test4.jsp"> <ul> <b>User ID</b> :<input type="text" name="userid">
Validation
Validation  Here is my form and what code should i write for validating it? - <form action="test4.jsp"> <ul> <b>User ID</b> :<input type="text" name="userid">
alert for validation
data should be in DD/MM/YYYY format only through javascript validation.    <html> <script type='text/javascript'> var...='document.form1.text1.focus()'> <form name="form1" action="#">
spring form validation
spring form validation  how can we validate a web form using spring, try to give an example of the form containing some fields and their validations,ASAP......   Please visit the following link: Spring form validation
Ajax form validation Example
Ajax form validation Example  Hi, I want to validate my ajax form. Please give me good code for Ajax form validation. Thanks   Hi, Read... to validate form in Ajax using jQuery framework. Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.