Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Making Two different function run on same element but for different events.

Posts: 19
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i am having a html page

I want to run two validation check on some of the fields like for username email.
I want to check their uniqueness (availability) from server using .ajax() and also to validate them if the field is empty or the entered data is not acceptable like(email: foo@hu).
What i have done is seprated the two checks as follows :
the ajax uniqueness (availability) check is set for the keyup event ;
and the validation check of required field is due till the submit.
Pretty much accomplished the above two thing except the preventDefault action of the submit button if the span errors are present due to "ajax" check.
here is my js

here in the above code the check for if any error before submission has a condition

which i included to check for the error of unique class generated due to the ajax calls.
but what i do is if the username is available i place a checkmark and "Available" message displayed which though is not a error but prevent my form submission .

So my questions are:
1.i want to know how can i allow submit if the error is due to the checkmark "available".?
2.Rather than checking for validation after submit, how can i accomplish it after the event blur from that field.means doing the two checks simultaneously on input field.
3.i have copied the same code thrice in the script for ajax checking uniqueness for three fields.Can i combine them into one?.or am i asking too much because the message displayed is different every time.
4.ajaxCompletet is not responding that's why i commented it out.Also after doin that my code is working the only problem the firebug console shows in the XML field is "Parsing error syntax location"what is that.?

Sorry for such a long post but after lots of lots of googling i end up finally asking here.
Thanks for patience
Vivek K Jain
Posts: 19
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all problems solved..
sometimes the solution is within we just need motivation to solve it by our self, thanks for that motivation
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic