How to: Validate special characters in a filed that are not allow only alpha numeric value it accepts
*This post is locked for comments
How to: Validate special characters in a filed that are not allow only alpha numeric value it accepts
*This post is locked for comments
@André Arnaud de Calavon...lowercase characters are allowed if i use the code i have wriiten and i agree with all the suggestion u said to me..and i note also to use more and more the regular expression also....
Hi Vinay,
Is your question answered? If so, mark the replies that helped you.
I want to make one additional note: The approach using regular expressions and strContains should be considered. Or you try to find some illegal characters (strContains), but the list might be incomplete. E.g. the character "o/oo" (Can't find it on my keyboard right now) is not listed, so allowed. I haven't tried the suggestion from Crispin, so I can't comment if the code should be correct or not.
Using regular expressions you tell which values are allowed. Also here you can have an incomplete list. In your example you used "A-Z 0-9". This is allowing capitals only. So lowercase characters are not allowed here.
Regular expressions are very powerful. Last week we defined a formula to check a string field for a valid entered date, including check on days per month and a leap year.
it done successfully after writing code in table method
public boolean validateWrite()
{
boolean ret;
TextBuffer txt = new TextBuffer();
ret = super();
txt.setText(this.teachername);
txt.regularExpressions(true);
if (txt.find("^[A-Z 0-9]+$"))
{
ret = true;//info("string contains only numbers");
}
else
{
this.teachername="";
throw error(" Conatin the Special Character");
}
return ret;
}
@Crispin John Augustine... I already done this also but not working donot the reason why the code is not restricted.. any special char in.....is there i also tried the txt buffer method but not working........
@Crispin John Augustine .... it doesnt throw any error also when i am done written it can easily move to the nxt field
i have written the code in the table
public boolean validateField(FieldId _fieldIdToCheck)
{
String30 teachername;
boolean ret;
ret = super(_fieldIdToCheck);
if(ret)
{
switch (_fieldIdToCheck)
{
case fieldNum (Validationtale,teachername):
if(strContains(teachername,"!@#$%^&*()_+=-[{]};:',<.>/?/-*+"))
{
Box::info("Special Character Is not Allowed ");
return checkFailed(strFmt("Invaild characters"));
}
else
{
break;
}
}
}
return ret;
}
but in form they are accepting the special charc....
André Arnaud de Cal...
294,430
Super User 2025 Season 1
Martin Dráb
233,043
Most Valuable Professional
nmaenpaa
101,158
Moderator