This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help please!

Thanks in Advance!

Regards,
sree
 
Amy Medrat
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Tamas Jano
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic