Friday, December 30, 2011

Validation for Text field

In Xpage, If we want to validate the Text filed, e have two choice...

1. Use of Xpage properties, We can validate

2. Use of java Script.,

In first one, We have one contradiction for validating the fields. If you want to move the page to home page, the validation does not allow you to go the Home page.

So the best way to validate the field is javaScript...
In @formula we have the @match for exact validation of fileds. Samething is here in java script is regular expression...

For Ex:

Text Field Validation:

var name=document.getElementById("#{id:inputText1}").value;
var patt=/([a-z][A-Z])/i;
var num=/([0-9])/i;
var numflag=name.match(num);
alert(numflag);
var flag=name.match(patt);
var len=name.length;
if(len==0)
{
alert("Enter the Name");
exit(0);
}
else if((flag==null) || (numflag!=null))
{
alert("Enter the Propername");
exit(0);
}
alert("Correct Value");



No comments:

Post a Comment