aspose file tools*
The moose likes Struts and the fly likes it gives like Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "it gives like"phone no must be an integer"!   why?" Watch "it gives like"phone no must be an integer"!   why?" New topic
Author

it gives like"phone no must be an integer"! why?

sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
Hi All,

i have created login for with fields like username and password,and registration form with fields like username ,password,email,address and phone no.

And i did the validations too!and modified the applications.properties file in resource folder.
And i created one DataBase table with that of five fields,and there i took 'phno int(15)'in MySqlquery.


Ok,now the browser displays the registration form,and now i am facing the problem here only :when i enter more than 10 numbers in phone no and try to click on submit,then it gives like"phone no must be an integer"!

I dont know the reason why it coming like this!
can anyone let me know the mistake i made?

Thank you in advance

Regards,
sree.
sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
Sorry!here in posting the above query i made a mistake.that is
Actually in creation DataBase table,i took like this:"phno varchar(15)".

Regards,
Sree
Tamas Jano
Ranch Hand

Joined: Feb 21, 2007
Posts: 55
You didn't make yourself clear but I'll give it a shot.

You are validating a phone number as an integer.
Java's max integer value is 2^31-1 that's 2147483647 and if I count correctly that's a 10 digit number. Go above this and you don't have an integer any more.

The rest is up to you to figure out. Use regexp to validate it and store it in varchar that would be a solution.
sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
Thank you Tamas,

yiu have given the sentence thst is
"Use regexp to validate it and store it in varchar that would be a solution."
i didn't get it!can you make me much more clarified?

Regards,
sree
sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
Any help please!

Thanks in Advance!

Regards,
sree
Amy Medrat
Greenhorn

Joined: Mar 05, 2006
Posts: 15
Use masking to verify the phone number rather than cheking the integer, sample below.

<field property="phone"
depends="maxlength, mask">

<arg1 name="maxlength" key="${var:maxlength}" />
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
<var>
<var-name>mask</var-name>
<var-value>^[0-9]*$</var-value>
</var>
</field>


medRat
Tamas Jano
Ranch Hand

Joined: Feb 21, 2007
Posts: 55
Yep, that's exactly what I was talking about.

You can even use formatting with regular expressions and it will accept the number only in certain formats you give (like xxx-xx.xx.xx).

Thanks Amy!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: it gives like"phone no must be an integer"! why?