Mobile Web Click button to send SMS to the specified number

Source: Internet
Author: User

First, preface

Some days ago, customers request production in the mobile phone site to create a text messaging function, you can send information to fixed mobile phone number, the other is very simple, let's show the following.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6D/DA/wKioL1VtrfOxwpM0AAHfg7B0KKk777.jpg "title=" Msg.jpg "alt=" Wkiol1vtrfoxwpm0aahfg7b0kkk777.jpg "/>


Second, HTML code

<form> <p><textarea name= "online" id= "online" placeholder= "Please enter text" ></textarea></p> <p class= "Online_button" ><a href= "sms:15812345678?body=" class= "btn" > Confirm send </a></p> <!-- The body is followed by the message content to be sent--></form>

Third, JS code

<script type= "Text/javascript" >    $ (function () {         $ (". Online_1 form a"). Bind (' click ', Function () {             //get the value in the input box              var textarea = $ ("#online"). Val ();             //Determine if the input box is empty             if   (textarea == null| | textarea ==  "") {                 alert ("Please enter the message content to be sent!") ");                 return  false;            }else{               &When nbsp; //is not empty, the input is added to the back of the sending message                  var href = $ (". Online_1 form a"). attr ("href");                 var msg =  href+textarea;                 $ (". Online_1 form a"). attr ("href", msg);             }        });     });</script>



This article from "Make a snail really good" blog, please be sure to keep this source http://smili.blog.51cto.com/8919945/1657652

Mobile Web Click button to send SMS to the specified number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.