Kamalam
Kamalam

Reputation: 1254

how can validate a value exists or not in database using jquery in spring Hibernate framework?

I Have a simple task that turned out to be not son simple ....I.e to Validate an input jsp form in spring hibernate based frame work...in that page i have to validate a text field (required,only English characters,unique(no repeat values should be inserted in db )

Fortunately i completed required & only English Characters validation now i am trying the other one for hours ..

for unique values ie(no repeated values should be saved in database) so validation should trigger a error message when we save the input page with same value in code field...

Help Me

Upvotes: 0

Views: 1063

Answers (2)

baba.kabira
baba.kabira

Reputation: 3171

To check for unique value you can do it in following ways.

  1. You can provide 'Check Availability' button/link next to input text which should be unique and on its click you make an ajax call which will check if the value is present or not and accordingly update user.
  2. You can use auto complete and as the user type you can show message already in use or available.
  3. You can allow user to input the value and check on submit value already exists in database and if yes show the message please select a different value and save the data only if all the validations pass.

Note: In case 1 and 2 if user submits the values even though you are showing value in use you have to stop it from being processed on server. Firebug and other javascript UI tools make it easy to by pass javascript easily.

As checking for unique value can be done on server side only. Ajax checking is the only way which can make it more intuitive and user friendly but you cannot neglect server side checks.

Hope this helps!!!!

Upvotes: 2

Ajinkya
Ajinkya

Reputation: 22720

IMHO jQuery can't help you to identify if values is present in database. You have to check it on server side.
Are you using any validation on server side like JSR 303? (You must keep server side validations along with client side validations)

Upvotes: 1

Related Questions