I create a membership website on website that required registration to see full website. I also want users register from specific country. To archive this goal, I also add SMS verification on my registration page and restrict phone number field only for country that I want i.e. 923. If Phone number is not start with 923 phone field's boarder goes red and an alert box apear. But this is only alert and "mental hit", registation form still can be submit. Vague people can use create fake account by using fake number (like recive sms online) Now I want that if phone field not start with 923, the Register button blocked and become unclickable other wise stay normal. How It possible?

Sorry for poor English. I hope you under stand what I want to do.Here is my Registration page. You can see phone number check script in footer. Thanks

You could always setup a JavaScript function, that if it is an incorrect phone number the CSS property of the submit button goes to display:none

Or a second option would be to contain an onClick function on the button, and verify the phone number. Depending on what it is you can then either return false or return true.

Good luck!

Thank you AHarrisGsy for help. I want to validate by 'onClick' function and need help how it possible in js. Actually I want to do same thing as onChange function of <input type="tel"> for "Register" button but with onClick function. When every thing is fine registration go straight but when phone field is incorrect phone form does not submit. Please help I am new to programming. I create this fuctions on JS Fiddle check and modify please. Thanks

Although adding the Javascript will work, I suggest you also add a check in the backend. It's easy to disable Javascript and submit invalid data anyway (or post directly with a bot).

Adding backend is more complex. I am beginer in coding.

Updated the JS Fiddle to work - I changed the Submit Button to a Button so it doesn't submit automatically when pressed and added an onclick() event so that when clicked, it validates the text and calles .submit() if necessary.

html5 has introduced a new attribute pattern which will restrict from submitting of form until input matches with the provided pattern.It will remove the use of javascript.But till now there is no full support by browsers for html5 tag.Before using it check with your requirement with browser compatibility.

 <input type="tel" name="num" pattern="[9][2][3][0-9]{7}">

Otherwise you have to use javascript.

Thank you IIM. I am looking some thing like this.

You can be use JS code for that, search this query on google i hope you will be get best JS code from there.
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.