Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Am trying to do a validation using minlength. The code works on jsfiddle but it doesn't work on my html page.

Full code:
<script type="text/javascript" src="//"></script>
<script type="text/javascript">
window.onload = function(){
        rules: {
            'phonenumber': {
                required: true,
                minlength: 10
<form action="order.php" method="post" id="form">
Your phone number :
        <input name="phonenumber" type="text" id='phonenumber' maxlength="10" autocomplete="off" onkeypress='return event.charCode >= 48 && event.charCode <= 57' placeholder="phonenumber">
<input type="submit" />
Updated 28-Dec-14 20:44pm

1 solution

Considering what you have working in the fiddle:

You need to add a script reference for JQuery's validation library (you may use following (on a CDN)):

Also, you need to remove an extra ) from your script.

Hope this helps.
Share this answer
404 valid 29-Dec-14 4:47am    
Seems like me not adding the validation reference and the extra ) was making the script not to work. But now it works fine. Thanks :)

script change:
window.onload = function ()
rules: {
'phonenumber': {
required: true,
minlength: 10
Agent__007 29-Dec-14 4:53am    
You are most welcome. Glad it helped.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900