Form Validation

Ads
 

Form Validation

Java script validation for checking special characters and white spaces and give an alert.Please help me urgent

Thanks in advance.

View Answers

March 16, 2011 at 4:55 PM

<script>
var iChars = "`[email protected]#$%^&*()+=-_:[]\;,./{}|\":<>?'";
    function hasWhiteSpace(s){
     reg = new RegExp(/^\s+$/);
     if (reg.test(s)) {
          alert("Please Check Your Fields For Spaces");
          return false;
     }
     return true;
}  
    function test(){
     var count=document.form.text.value.length;
     for (var i = 0; i < count; i++) {
     if ((iChars.indexOf(document.form.text.value.charAt(i)) != -1)||hasWhiteSpace(document.form.text.value)) 
     {
     alert("Contains special characters or whitespace. These are not allowed.");
     document.form.text.value="";
     return false;
      }
    }   
     }
     </script>
     <form name="form" onsubmit="return test();">
     Enter data: <input type="text" name="text">

     <input type="submit" value="submit">
     </pre>
     </form>

Ads









Related Tutorials/Questions & Answers:
form validation
form validation  how the form validation is done in jsf form using 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
Advertisements
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
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
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
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
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
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation...;Have a look at the following link: JQuery Form Validation The above link provide you a good example of validating a form using jquery with illustration
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation...;Have a look at the following link: JQuery Form Validation The above link provide you a good example of validating a form using jquery with illustration
Html form validation using jquery
Html form validation using jquery  Hi i am using form with html. Form elements like textbox, radio,checkbox,listbox i was used now how to validate the elements using submit jquery option
HTML form validation using jquery
HTML form validation using jquery  Is there any way for validating html elements common under a class by giving its class name in jquery validation code..that means validating all elements by using its class name if those
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
Example of login form validation in struts2.2.1framework.
Example of login form validation in struts2.2.1 framework. In this example, we will introduce you to about the login form validation in struts2.2.1 framework. Our login form validation example does not validate the user against
ModuleNotFoundError: No module named 'django-tastypie-with-file-upload-and-model-form-validation'
-and-model-form-validation'  Hi, My Python program is throwing following...-and-model-form-validation' How to remove the ModuleNotFoundError: No module named 'django-tastypie-with-file-upload-and-model-form-validation'
ModuleNotFoundError: No module named 'django-tastypie-with-file-upload-and-model-form-validation'
-and-model-form-validation'  Hi, My Python program is throwing following...-and-model-form-validation' How to remove the ModuleNotFoundError: No module named 'django-tastypie-with-file-upload-and-model-form-validation'
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...='_blank';return true;"> </div> <form name=f2 method=POST
Please provide jquery inline form validation for the code
Please provide jquery inline form validation for the code   <html> <head> <meta http-equiv="Content-Type" content="text/html...="white"> <form action="Student1Servlet" method="post" enctype="multipart/form
Please Provide jquery inline form validation
Please Provide jquery inline form validation  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd...;/head> <body> <form action="LabAccountServlet" method="post"><
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
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how... am giving a simple example for form validation using Javascript. Example...;head> <title>Form Validation Example</title> <script type
validation
validation  validation
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
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter only numerical values in textbox , if he enters string values then it should
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
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
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
Form validation in javascript using jsf page  ?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...; &lt;f:view&gt; &lt;h:form id="form2" onsubmit
Validation
); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
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">

Ads