aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Making Two different function run on same element but for different events. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Making Two different function run on same element but for different events." Watch "Making Two different function run on same element but for different events." New topic
Author

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

Vivek K Jain
Greenhorn

Joined: Mar 17, 2013
Posts: 19

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
Greenhorn

Joined: Mar 17, 2013
Posts: 19

all problems solved..
sometimes the solution is within we just need motivation to solve it by our self, thanks for that motivation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making Two different function run on same element but for different events.