1

I have text box (telephone number) which is coming under the div tag not coming under the form tag. I have to validate this text box using RegEx pattern. If the the pattern is not matched I should not allow the users to save the screen.

I thought of using jquery validator

$.validator.addMethod

$('#form').validate

But the problem is this text box doesn't comes under form tag. What are the other options I can choose?

1 Answer 1

2

It would really help to see some code.

Without code I can tell you this, there are SEVERAL ways to achieve what you want very easy.

If you're textbox (and i'm just assuming here) is a noraml input or textbox, you could do validation on either the keypress (checking if a number is being entered, and then checking the input value as a whole, return false if there is an error and no character will be inserted) or you could check them on 'blur', this would give you a function to check validation when they click anything else other than that textbox.

Or, in jQuery, you can use a form ajax submit and use the function 'beforeSend' to validate form before posting and return false if there is an error.

Gimmie a lil example detail code and i'll show you more...

also, is there any reason you can't include the textbox in the form?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.