Locale Specific Date validations through JavaScript/Ajax...

Ads
 

Locale Specific Date validations through JavaScript/Ajax...

Hi,

I am developing an JSP Application which supports I18N(Internationalization). In my JSP Page, when the user selects language(It may be Chinese or French or etc.), how to manipulate date validations through JavaScript or Ajax?

Thanks in Advance, Sreenivasulu Arveti.

View Answers

October 25, 2010 at 7:00 PM

Hi,

You can write normal JavaScript validation, but change the error/information message as per your local.

It can be done in JSP file.

For example

You if your validation function is like this:

if(theform.myfield.value.length()==0){
  alert("Please enter MY Field!");
  return false;
}

You can write the above code as shown below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Form Validation</TITLE>
<%
String messageFormField1="Please enter MY Field!";
If(lanuage="Denmak"){
    //You can even Get this value from lanuage file.
    messageFormField1="Language translation here!"; 
}

%>
  <Script language="JavaScript">
    function validateForm(theForm){
        if(theform.myfield.value.length()==0){
          alert("<%=messageFormField1%>");
          return false;
        }

        return true;
    }
  </Script>
 </HEAD>

 <BODY>
  <form onsubmit="return validateForm(this)">
    <!-- Your form fileds and submit button HTML code -->
  </form>
 </BODY>
</HTML>

Hope above code will help you. Keep on posting your queries related to this in this post.

Thanks


October 25, 2010 at 7:29 PM

Hi,

Read more about using cookies in JSP at JSP Cookies Example tutorial page.

Thanks

Ads









Related Tutorials/Questions & Answers:
Formatting and Parsing a Locale-Specific Percentage
Formatting and Parsing a Locale-Specific Percentage In this section, you will learn how to format and parse a locale-specific percentage. On the basis... are going to format a number into locale specific percentage using NumberFormat class
Formatting and Parsing Locale-Specific Currency
Formatting and Parsing Locale-Specific Currency In this section, you will learn how to format and parse the locale specific currency. Through the formatting... are going to format the number into locale specific currency using NumberFormat class
Advertisements
Formatting number as per specific locale in java
Formatting number as per specific locale in java  Hi, I am trying to print the number as per locale. I tried below, but it still prints in English locale. public class loctest { public static void main(String[] args
Set Date Parameter to get specific value
Set Date Parameter to get specific value  How to set the date parameter or fetch a specific data records based on date? For example fetching the two or three months old records
Java Locale
Java Locale         A locale class in java api represents a specific geographical, political, or cultural region. In java computing, locale defines a set of parameters
Jdatechooser : not able to fetch date in a specific format
Jdatechooser : not able to fetch date in a specific format  get date... at this website now i can't fetch date from it ina a specific format... but i am able to get date i am using netbeans i have tried all groups no one seems to know
validations
validations  How to get All Client and server side validations in spring using jsp   Please visit the following link: Spring Validation Example
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?  how to done calculation for dynamic generated textboxes in jquery/javascript/ajax
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
validations - Struts
validations  log in page with validations user name must be special character and one number and remining is alphabetes in struts
Spring Validations
Spring Validations  Hi.. i need code for validations using spring annotations
What is the Locale class?
What is the Locale class?  What do you understand about locale class in java program. thanks,   Hi, The Locale class in Java is Java application API that stands for a specific geo-location, political or cultural
Date Example
; In this section we are discussing about the specific date using the Date... showing specific date and time");         Date particulardate1 = new Date(24L*60L... GMT+05:30 2007 Date object showing specific date and time
Validations
Validations
Validations  Javascript validation is working fine in Internet... = "Javascript"> function checkEmail() { if (/^\w...;script language = "Javascript"> function checkEmail
Struts 2 Date Validator
checks if the date supplied is within a specific range. If it is valid and lies...Struts 2 Date Validator       The Date validator in the Struts 2 Framework checks whether the supplied date lies
JSP Locale
JSP Locale          JSP Locale is used to get the preferred locale of the user. A user can configure their browser with a US language locale ("en
Mysql Date Order By
Mysql Date Order By       Mysql Date Order By is used to sort the records of the table by specific column.. Understand with Example The Tutorial covers an example from 'Mysql Date
ModuleNotFoundError: No module named 'validations'
ModuleNotFoundError: No module named 'validations'  Hi, My Python... 'validations' How to remove the ModuleNotFoundError: No module named 'validations' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'validations'
ModuleNotFoundError: No module named 'validations'  Hi, My Python... 'validations' How to remove the ModuleNotFoundError: No module named 'validations' error? Thanks   Hi, In your python environment
Sql Date Conversion
Sql Date Conversion       The Tutorial illustrate an example from 'Sql Date Conversion'. To understand this, we show you an example that return you the specific format
java validations
" /> <script type="text/javascript"> function validateForm...; if (f.length<20) { alert("Address too short"); return false; } var q=document.retailer.contact_no.value; if (q==null || q=="") { alert
date
date   how to insert date in database? i need coding
Formatting and Parsing a Time for a Locale
. This class formats and parses both date and time for any locale. To format... = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale) .format(new Date...Formatting and Parsing a Time for a Locale In this section, you will learn how
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  i want difference between the date entered in a jtextfield and the system date in java
Formatting and Parsing a Number for a Locale
Formatting and Parsing a Number for a Locale In this section, you will learn how to format and parse a number for a Locale. Formatting converts a date, time... of the date, time, number, or message. Java has provide different classes

Ads