Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

Need jquery Validation help to make it wirth with jquery UI submission

Hi Experts I need your help in fixing up my jquery UI form submission validation to work with jquery Validation Plugin. Currently the Jquery UI code i am using for submission is the below:

submitUsers = function() {
    $('#tabs_users>#ui-tabs-2').on('click', '.submitusers', function() {
        var dataString = $("form").serialize();
            type: "POST",
            url: "save.cfm?mode=useraction" + '&submission=' + Math.random(),
            cache: false,
            data: dataString,
            success: function(result) {
                var i = result;
                $('#tabs_users>#ui-tabs-2').off('click', '.submitusers');
                if ($.trim(i) == 'Warning! Country with Same Name already Exists' || $.trim(i) == 'Warning! Code for the Entered Country Exists for another Country' || $.trim(i) == 'Warning! Code and Country already Exists') {
                    setTimeout(function() {
                    }, 3000);
                } else if ($.trim(i) == 'Cool! Processed Successfully') {
                    setTimeout(function() {
                    }, 3000);
                } else {
                    setTimeout(function() {
                    }, 3000);

Open in new window

I want to make the validation to work with this, How can i add validation plugin to this.

My form has following fields

<form id="adduser" name="adduser">
        <input type="text" id="username" class="input-block-level-inputfields" name="username" placeholder="Username">
        <input type="password" id="password" name="password" class="input-block-level-inputfields" placeholder="Password Please" />
        <label>Full Name</label>
        <input type="tel" name="fullname" id="fullname" class="input-block-level" placeholder="Your Complete Full Name" />
        <label>Password Hint</label>
        <input type="text" name="passwordhint" id="passwordhint" class="input-block-level-inputfields" placeholder="Provide Password Hint (optional)" />
        <label>Security Question</label>
        <input type="text" class="input-block-level" placeholder="Security Question" id="question" name="question" />
        <input type="text" class="input-block-level" placeholder="Security Answer to the above Question" id="answer" name="answer" />
        <label>Email Address</label>
        <input type="text" name="email" id="email" placeholder="Email Address" class="input-block-level" />
        <select name="rolesection" id="rolesection" class="input-block-level-inputfields">
        	<option value="1">Admin</option>
            <option value="2">Staff</option>
            <option value="3">User</option>
        <select name="confirmed" id="confirmed" class="input-block-level-inputfields">
        	<option value="1">Confirmed</option>
            <option value="2">Blocked</option>
        <br />
        <input type="button" class="btn submitusers" name="sbtuser" id="sbtuser" value="Submit" onclick="javascript:submitUsers();">

Open in new window

Avatar of darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image


What have you tried so far?

Avatar of Coast Line


honestly few tricks but none worked so far and kept deleting after every failed try
Using, you need to include the plugin
Attached the validation to the page:


add a class to the form fields, so for email address:

<input type="text" class="required email" name="email" id="email" placeholder="Email Address" class="input-block-level" />

and that will validate this field, you will just need to disable the button then until the form is valid
Thanks, I was trying with this plugin, But my question is:

1. where i add this, when i am doing the on click event of the function or before

2. how can i stop its processing unless all errors has been cleared.
add it before,
on keyup call $("#adduser").valid() this will return T/F and then based on this enable/disable the submit button
i want to have validation on submit of the Page, not on keyup. anyways, i am still looking for solution. Thanks anyways, when i do it, i will post the answer here
Avatar of mcnute
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, But it is going in both the commands, if and the lese too
You're doing a validation in your ajax with code that's coming from the server side. So it is not possible to validate data which is processed by the server without submitting the form.

What you can do is to populate the form with the primary submitted values stored in your i variable and sent that back to the form when thir first if clause and or the else is true.


What would make more sense is to submit that form to the same page the form is on (without ajax involved) and on the server side redirect to a success page if data was alright, or just stay on the original form page and 'paste' original input values in the form, so the user doesn't have to input it again and display error messages accordingly.

Hope I got the point for you.

Good Luck anyways!